Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search


< EclipseLink‎ | Examples‎ | JPA
Revision as of 12:04, 26 November 2009 by Unnamed Poltroon (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

You may use the org.eclipse.persistence.jpa.JpaHelper class to obtain an EntityManager.

Using a server session

EntityManagerFactory emf = JpaHelper.createEntityManagerFactory(serverSession);
EntityManager em = emf.createEntityManager();

Using a sessions.xml file

If you want to use EclipseLink or Oracle TopLink's native XML metadata within EclipseLink JPA this can be accomplished using API:

EntityManagerFactory emf = JpaHelper.createEntityManagerFactory(sessionName);
EntityManager em = emf.createEntityManager();

or through the use of persistence unit properties in your persistence.xml:

<persistence xmlns=""
          xsi:schemaLocation=" persistence_1_0.xsd"
    <persistence-unit name="my-app" transaction-type="RESOURCE_LOCAL">
             <property name="eclipselink.sessions-xml" value="org/my-app/persistence/sessions.xml"/>
             <property name="eclipselink.session-name" value="my-app"/>

Back to the top