Can @Transational be used in Spring, Eclipselink & Tomcat?

HiAll, I was confused by the EclipseLink for Tomcat documentation that said:

Limitations for JPA: There is no container-managed control injection available for @PersistenceContext - use Persistence.createEntityManagerFactory (JTA_PU_NAME)

as well as this question and answer :

but a typical Spring JPA configuration looks like this, so you donโ€™t need to create an EntityManager manually: @PersistenceContext private EntityManager em;

So the question is: can I use this @PersistenceContext annotation for entityManager to make sure it will be created automatically, and I donโ€™t need to manually create it?

The @Transactional annotation is currently not working properly, and I'm afraid that this involves creating the entity manager manually!

Please need help.

0
source share
1 answer

The EclipseLink documentation says that @PersistenceContext not handled by Tomcat on its own. However, if you use Spring, @PersistenceContext processed by Spring so you can use it.

See also:

+2
source

All Articles