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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With