Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Examples/JPA/Configure"
< EclipseLink | Examples | JPA
Line 3: | Line 3: | ||
* Jar(s) containing your: | * Jar(s) containing your: | ||
** Persistence.xml - which defines your persistence units | ** Persistence.xml - which defines your persistence units | ||
+ | *** It must be defined in the meta-inf/ | ||
+ | *** Example: | ||
+ | <code><pre> | ||
+ | <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/advanced-entity-mappings.xml</mapping-file> | ||
+ | ... | ||
+ | <jar-file>jpa-xml-only-model-tests.jar</jar-file> | ||
+ | ... | ||
+ | <exclude-unlisted-classes>false</exclude-unlisted-classes> | ||
+ | |||
+ | <properties> | ||
+ | ... | ||
+ | </properties> | ||
+ | </persistence-unit> | ||
+ | </pre></code> | ||
** Entities, Embeddable and MappedSuperclasses | ** Entities, Embeddable and MappedSuperclasses | ||
*** These classes should be decorated with the necessary annotations, and/or | *** These classes should be decorated with the necessary annotations, and/or |
Revision as of 10:32, 16 October 2007
To use JPA you will need to have the following configurations:
- Jar(s) containing your:
- Persistence.xml - which defines your persistence units
- It must be defined in the meta-inf/
- Example:
- Persistence.xml - which defines your persistence units
<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/advanced-entity-mappings.xml</mapping-file>
...
<jar-file>jpa-xml-only-model-tests.jar</jar-file>
...
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
...
</properties>
</persistence-unit>
- Entities, Embeddable and MappedSuperclasses
- These classes should be decorated with the necessary annotations, and/or
- Be defined in the orm.xml using the XML descriptors.
- Entities, Embeddable and MappedSuperclasses
- Properties - use these 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.