Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/OutsideContainer"

(New page: Users may also use the EntityManager API outside the container. You may use the org.eclipse.persistence.jpa.JpaHelper class to obtain an EntityManager. == Using a server session == <code>...)
 
Line 5: Line 5:
 
EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(serverSession);
 
EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(serverSession);
 
EntityManager em = emf.createEntityManager();
 
EntityManager em = emf.createEntityManager();
</pre><code>
+
</pre></code>
  
 
== Using a sessions.xml file ==
 
== Using a sessions.xml file ==
Line 11: Line 11:
 
EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(sessionName);
 
EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(sessionName);
 
EntityManager em = emf.createEntityManager();
 
EntityManager em = emf.createEntityManager();
</pre><code>
+
</pre></code>
  
 
Or you may use an EntityManager from a persistence.xml file.
 
Or you may use an EntityManager from a persistence.xml file.

Revision as of 10:16, 15 October 2007

Users may also use the EntityManager API outside the container. You may use the org.eclipse.persistence.jpa.JpaHelper class to obtain an EntityManager.

Using a server session

EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(serverSession);
EntityManager em = emf.createEntityManager();

Using a sessions.xml file

EntityManagerFactory emf = org.eclipse.persistence.jpa.JpaHelper.createEntityManagerFactory(sessionName);
EntityManager em = emf.createEntityManager();

Or you may use an EntityManager from a persistence.xml file.

Using a persistence unit name

EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName, propertiesMap);
EntityManager em = create.getEntityManager();

Users will then need to specify the database properties in the propertiesMap and are resonsible for building their persistence.xml file and having it available on the classpath.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.