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

From Eclipsepedia

Jump to: navigation, search
m (added xrefs to elug)
(Fix broken link to latest API)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
To use JPA you will need to have the following configurations available:
+
[[Category:EclipseLink/Example/JPA|Configuration]]
  
* '''[[Packaging_and_Deploying_EclipseLink_JPA_Applications_%28ELUG%29#How_to_Specify_the_Persistence_Unit_Name|Persistence.xml]]''' - which defines your persistence units and should be in the '''meta-inf/''' directory.  
+
To use JPA you will need to have the following configured:
 +
 
 +
* '''persistence.xml''' - which defines your persistence units and should be in the '''meta-inf/''' directory of your persistence unit jar file, or classpath.  
 
<blockquote>
 
<blockquote>
 
<source lang="xml">
 
<source lang="xml">
Line 8: Line 10:
  
 
   <!-- By default your mappings can be defined in orm.xml file, -->
 
   <!-- By default your mappings can be defined in orm.xml file, -->
   <!-- which is discovered automatically.                       -->                                     
+
   <!-- which is discovered automatically.                       -->                                     
 
   <mapping-file>META-INF/my-mappings.xml</mapping-file>
 
   <mapping-file>META-INF/my-mappings.xml</mapping-file>
 
   ...
 
   ...
 
   <jar-file>my-additional-jar.jar</jar-file>
 
   <jar-file>my-additional-jar.jar</jar-file>
 
   ...
 
   ...
 +
  <!-- Enables auto discovery of persistent classes, -->
 +
  <!-- otherwise they must be listed using <class>  -->
 
   <exclude-unlisted-classes>false</exclude-unlisted-classes>
 
   <exclude-unlisted-classes>false</exclude-unlisted-classes>
  
Line 23: Line 27:
  
  
* [[Introduction_to_EclipseLink_JPA_%28ELUG%29#Configuring_an_Entity|Entities]], [[Introduction_to_EclipseLink_JPA_%28ELUG%29#.40Embeddable|Embeddable]] and [[Introduction_to_EclipseLink_JPA_%28ELUG%29#.40MappedSuperclass|MappedSuperclasses]]
+
* [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Creating_and_Configuring_Entities|Entity]], [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Embeddable|Embeddable]] and [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/MappedSuperclass|MappedSuperclass]]
 
** These classes should be decorated with the necessary annotations, and/or
 
** These classes should be decorated with the necessary annotations, and/or
 
** Be defined in the orm.xml (or some other mapping file) using the XML descriptors.
 
** Be defined in the orm.xml (or some other mapping file) using the XML descriptors.
 
   
 
   
  
* Properties - use these properties to further configure your JPA application.
+
* Properties - use these persistence.xml or persistence unit properties to further configure your JPA application.
** javax.persistence.transactionType - Standard JPA PersistenceUnitTransactionType property, JTA or RESOURCE_LOCAL.
+
** "javax.persistence.transactionType" - Standard JPA PersistenceUnitTransactionType property, "JTA" or "RESOURCE_LOCAL".
** javax.persistence.jtaDataSource - Standard JPA JTA DataSource name.
+
** "javax.persistence.jtaDataSource" - Standard JPA JTA DataSource name.
** javax.persistence.nonJtaDataSource - Standard JPA non-JTA DataSource name.
+
** "javax.persistence.nonJtaDataSource" - Standard JPA non-JTA DataSource name.
 +
** "javax.persistence.jdbc.driver" - Standard JPA 2.0 JDBC driver class name for JSE deployments (was "eclipselink.jdbc.driver" in EclipseLink 1.1).
 +
** "javax.persistence.jdbc.url" - Standard JPA 2.0 JDBC URL for JSE deployments (was "eclipselink.jdbc.url" in EclipseLink 1.1).
 +
** "javax.persistence.jdbc.user" - Standard JPA 2.0 database user for JSE deployments (was "eclipselink.jdbc.user" in EclipseLink 1.1).
 +
** "javax.persistence.jdbc.password" - Standard JPA 2.0 database password for JSE deployments (was "eclipselink.jdbc.password" in EclipseLink 1.1).
  
 +
For a complete list of persistence unit properties see, [http://www.eclipse.org/eclipselink/api/2.4/index.html?org/eclipse/persistence/config/PersistenceUnitProperties.html PersistenceUnitProperties]
  
 +
----
  
See [[EclipseLink/UserGuide/Developing JPA Projects (ELUG)|Developing JPA Projects]] in the ''[[EclipseLink/UserGuide|EclipseLinkUser's Guide]]'' for details.
+
See "Configuring Persistence Units" in the ''[http://www.eclipse.org/eclipselink/documentation/ Understanding EclipseLink (concepts guide)]'' and the ''[http://www.eclipse.org/eclipselink/documentation/ EclipseLink Solutions Guide] ''for details.

Latest revision as of 12:31, 15 March 2013


To use JPA you will need to have the following configured:

  • persistence.xml - which defines your persistence units and should be in the meta-inf/ directory of your persistence unit jar file, or classpath.
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 
  <!-- By default your mappings can be defined in orm.xml file, -->
  <!-- which is discovered automatically.                       -->                                     
  <mapping-file>META-INF/my-mappings.xml</mapping-file>
  ...
  <jar-file>my-additional-jar.jar</jar-file>
  ...
  <!-- Enables auto discovery of persistent classes, -->
  <!-- otherwise they must be listed using <class>  -->
  <exclude-unlisted-classes>false</exclude-unlisted-classes>
 
  <properties>
    ...
  </properties>
</persistence-unit>


  • Entity, Embeddable and MappedSuperclass
    • These classes should be decorated with the necessary annotations, and/or
    • Be defined in the orm.xml (or some other mapping file) using the XML descriptors.


  • Properties - use these persistence.xml or persistence unit properties to further configure your JPA application.
    • "javax.persistence.transactionType" - Standard JPA PersistenceUnitTransactionType property, "JTA" or "RESOURCE_LOCAL".
    • "javax.persistence.jtaDataSource" - Standard JPA JTA DataSource name.
    • "javax.persistence.nonJtaDataSource" - Standard JPA non-JTA DataSource name.
    • "javax.persistence.jdbc.driver" - Standard JPA 2.0 JDBC driver class name for JSE deployments (was "eclipselink.jdbc.driver" in EclipseLink 1.1).
    • "javax.persistence.jdbc.url" - Standard JPA 2.0 JDBC URL for JSE deployments (was "eclipselink.jdbc.url" in EclipseLink 1.1).
    • "javax.persistence.jdbc.user" - Standard JPA 2.0 database user for JSE deployments (was "eclipselink.jdbc.user" in EclipseLink 1.1).
    • "javax.persistence.jdbc.password" - Standard JPA 2.0 database password for JSE deployments (was "eclipselink.jdbc.password" in EclipseLink 1.1).

For a complete list of persistence unit properties see, PersistenceUnitProperties


See "Configuring Persistence Units" in the Understanding EclipseLink (concepts guide) and the EclipseLink Solutions Guide for details.