Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Object/relational mapping XML file named orm.xml may be specified in the *META-INF directory in the root of the
    persistence unit.
  • Object/relational mapping XML file named orm.xml may be specified in the META-INF directory of any jar file
    referenced by the persistence.xml.

...

  • All classes contained in the root of the persistence unit are also searched for annotated managed persistence classes and any mapping metadata annotations found on them will be processed, or they will be mapped using the mapping annotation defaults.
  • If it is not intended that the annotated persistence classes contained in the root of the persistence unit be included in the persistence unit, the exclude-unlisted-classes element should be used.
  • The exclude-unlisted-classes element is not intended for use in Java SE environments.

...

  • The classes and/or jars that are named as part of a persistence unit must be on the classpath. Referencing them from the persistence.xml file does not cause them to be placed on the classpath.

...

The following XML fragment illustrate the use of properties element. The specified properties and the values enable JPA to connect to VehicleDB database created in the embedded derby of geronimo server.

Note
Code Block
XML
XML
borderStylesolid
<persistence-unit name="Inheritence">
 <description>Single Table Inheritence example</description>
 <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
 <class>com.jpa.RoadVehicle</class>
 <class>com.jpa.Car</class>
 <class>com.jpa.Coupe</class>
 <class>com.jpa.Motorcycle</class>
 <class>com.jpa.Roadster</class>
 <properties>
   <property name="openjpa.ConnectionURL" value="jdbc:derby:VehicleDB" />
   <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver" />
   <property name="ConnectionUserName" value="app" />
   <property name="openjpa.jdbc.SynchronizeMappings" value="false" />
 </properties>
</persistence-unit>

The above properties are specific to OpenJPA provider. The OpenJPA provider reads these properties and creates appropriate EntityManagerFactory. The properties supported by OpenJPA is at this link