We have planned to migrate spring application and use Java enterprise edition 6 / JSF / Hibernate with Tomcat 7 in our project, no TomEE please, and we need the following requirements to be fulfilled :
* EntityManager to be injected in stateless session beans
* TransactionManager will be JTA with atomikos
Please let me know how to inject the entitymanager with @PersistenceContext, entitymanager is always null in tomcat, and also the configurations to be done for using JTA as the transaction manager
My most common projects are in a similar form, although I don't use the EJB term "stateless session bean".
I actually have 2 persistence layers: The DAO layer, which handles basic single-table operations (CRUD/finders), and the Service layer, which handles sets of persistent objects handle as single transactions.
For both layers, I use the @Repository annotation on their respective classes, which, when paired with proper Spring configuration allows them to be referenceable via the auto-wiring mechanism and the JSF/Spring EL bridge. I use the @Transactional annotation to ensure automatic transaction framing.
I don't inject the DAOs with @PersistenceContext, I inject them with @EntityManager. The Service beans don't have any explicit persistence context, since they employ the DAOs to do the actual database persistence operations.
Got idle CPU cycles? Join the war on COVID-19 by donating them to find the coronavirus' weak spots. folding@home Runs in the background. https://foldingathome.org
posted 5 years ago
In my few days exploring JEE 6 /tomcat JTA / Resource Local transactions is possible with much more easier than spring. Even the entitymanager can be injectable in JEE 6 . From whatever I have explored spring is nothing more than added weight, when all things is possible and also restful soa in JEE 6 , whatever you can do with spring, Why Spring??? Just a overload to JEE 6
Friends help you move. Good friends help you move bodies. This tiny ad will help: