Hello,
I am very new to Hibernate so my question might be stupid but I cannot find any resource that could help me solve my problem.
I have application (first few lines) in CMT environment on Tomcat (using JOTM). I use EntityManager and Annotations. I am trying to figure out how to demarcate transactions using annotations. Hibernate EntityManager documentation says:
Quote:
In other words, all you have to do in a managed environment is call EntityManagerFactory.getEntityManager() or inject the EntityManager, do your data access work, and leave the rest to the container. Transaction boundaries are set declaratively in the annotations or deployment descriptors of your session beans. The lifecycle of the entity manager and persistence context is completely managed by the container.
I would like to use the
bold approach.
In my code I use this method to get the entity manager (code from documentation):
Code:
EntityManager em = factory.getEntityManager();
My 'factory' is created in a singleton class.
I searched Hibernate Annotations documentation and forum and didn't find any mention about the way I should demarcate the transactions using annotations.
Could somebody direct me to a resource describing the annotation to be used or just write "do it this way"?
Thank you.