Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Spring Data Repositories as Vaadin JPAContainer

Is it possible to use the org.springframework.data.jpa.repository.JpaRepository Repositories as JPAContainer for Vaadin?

We are setting up a new Vaadin 7 Project from scratch with Spring 3.2.

The Spring integration is done with Spring Vaadin Integration Addon.

like image 289
d0x Avatar asked Aug 07 '13 15:08

d0x


1 Answers

As far as you can get EntityProvider from JPARepository or somewhere else you can use JPAContainer like this:

EntityManager entityManager = getEntityManager(Campaign.class));
MutableLocalEntityProvider<Campaign.class)> provider;
provider = new CachingMutableLocalEntityProvider<Campaign.class)>(Campaign.class), entityManager);
provider.setTransactionsHandledByProvider(false);
JPAContainer<Campaign> container = new JPAContainer<Campaign>(Campaign.class);       container.setEntityProvider(EntityProviderUtil.get().getEntityProvider(Campaign.class));

or jsut simple

EntityManager entityManager = getEntityManager(Campaign.class));
JPAContainer<Campaign> container = JPAContainerFactory.make(Campaign.class, entityManager)

Well, you should read following post and decide if you did not want to use you JPARepository as a model layer and wrap it into BeanItemContainer, cuz JPAContainer looks good but has some performance issues from my point of view.

JPAContainer issues and different approach

MVP pattern and POJO binding with Hibernate

like image 196
Milan Baran Avatar answered Oct 05 '22 19:10

Milan Baran