Jump to: navigation, search

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

Line 2: Line 2:
  
 
== Using a server session ==
 
== Using a server session ==
<code><pre>
+
<source lang="java">
 
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>
+
</source>
  
 
== Using a sessions.xml file ==
 
== Using a sessions.xml file ==
Line 11: Line 11:
 
If you want to use EclipseLink or Oracle TopLink's native XML metadata within EclipseLink JPA this can be accomplished using API:  
 
If you want to use EclipseLink or Oracle TopLink's native XML metadata within EclipseLink JPA this can be accomplished using API:  
  
<code><pre>
+
<source lang="java">
 
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>
+
</source>
  
 
or through the use of persistence unit properties:
 
or through the use of persistence unit properties:

Revision as of 16:01, 23 June 2008

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)