Hi,
I’m trying to use a JPAContainer with an EntityManager and transaction managed by Spring.
I use SpringVaadinIntegration add-on to inject an EntityManager in my UI and create the JPAContainer with
This work fine to load the entities, but fail when adding a new one with this exception
java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead
I suppose that this is because the JPAContainer try to create a JPA transaction but the EntityManager expect a Spring transaction as it is managed by Spring.
Is there a way to tell the JPAContainer to use Spring transactions instead of JPA transactions?
Hi, I’d suggest to forget the JPAContainer. If you have a Spring Data repository, you can really easily and efficiently wire it to Table/ComboBox using Viritin. Check out
my recent arcticle about it.
for building container need to use with EntityManager like
@PersistenceContext(unitName = "customerdb")
EntityManager em;
and after it all queries need to create manualy like:
public List getGroups() {
return em.createQuery("SELECT e from PhoneBookGroup e",
PhoneBookGroup.class).getResultList();
}
[/code]Is it posible to use with basic spring JpaRepository object (that I already have in my old project) to build Container for vaadin like [code]
public interface BookRepository extends JpaRepository<PhoneBookGroup, Long> {
List<PhoneBookGroup> findByTitle(String title);
}
Please, post link to example or documentation with using spring data and viritin container together if you have?
Thank you !