java - Using JSF, JPA and DAO. Without Spring? -
So far, I still work with JSF and JPA without DAO. Now I want to use the DAO. But how can I start EntityManager in DAO classes?
Public category AdresseHome {@PersistenceContext Personal EntityManager EntityManager; Public Zero continues (Adresse transientInstance) {log.debug ("Adresse instance" issued); Try {EntityManager.persist (transientInstance); Log.debug ("be successful"); } Hold (runtime expansion) {log. Terror ("frequent failure", again); Throw away; Thanks
If your container does not inject EntityManager for you You can get it:
EntityManagerFactory Factory; Factory = stability. Couture antimynganger factor ("zapestast"); EntityManager em = factory.createEntityManager ();
Where "jpatest" from the unit defined in your persistence.xml
Comments
Post a Comment