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

From Eclipsepedia

Jump to: navigation, search
Line 1: Line 1:
You may use the org.eclipse.persistence.jpa.JpaHelper class to obtain an EntityManager.
+
[[Category:EclipseLink/Examples/JPA|NativeMetadata]]
 +
 
 +
You may use the [http://www.eclipse.org/eclipselink/api/1.2/org/eclipse/persistence/jpa/JpaHelper.html <code>org.eclipse.persistence.jpa.JpaHelper</code>] class to obtain an EntityManager.
  
 
== Using a server session ==
 
== Using a server session ==

Revision as of 11:56, 26 November 2009


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

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

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

or through the use of persistence unit properties:

TODO: Example of XML property config

TODO: Example of property config using properties map passed to Persistence.createEntityManagerFactory("pu-name", properties)