Chapter 6.  Metadata

Table of Contents

1. Metadata Factory
2. Metadata Repository
3. Additional JPA Metadata
3.1. Datastore Identity
3.2. Surrogate Version
3.3. Persistent Field Values
3.4. Persistent Collection Fields
3.5. Persistent Map Fields
4. Metadata Extensions
4.1. Class Extensions
4.1.1. Fetch Groups
4.1.2. Data Cache
4.1.3. Detached State
4.2. Field Extensions
4.2.1. Dependent
4.2.2. Load Fetch Group
4.2.3. LRS
4.2.4. Inverse-Logical
4.2.5. Read-Only
4.2.6. Type
4.2.7. Externalizer
4.2.8. Factory
4.2.9. External Values
4.3. Example

The JPA Overview covers JPA metadata in Chapter 5, Metadata . This chapter discusses OpenJPA's extensions to standard JPA metadata.

1.  Metadata Factory

The openjpa.MetaDataFactory configuration property controls metadata loading and storing. This property takes a plugin string (see Section 4, “ Plugin Configuration ”) describing a concrete org.apache.openjpa.meta.MetaDataFactory implementation. A metadata factory can load mapping information as well as persistence metadata, or it can leave mapping information to a separate mapping factory (see Section 5, “ Mapping Factory ”). OpenJPA recognizes the following built-in metadata factories:

JPA has built-in settings for listing your persistent classes, which the JPA Overview describes. OpenJPA supports these JPA standard settings by translating them into its own internal metadata factory properties. Each internal property represents a different mechanism for locating persistent types; you can choose the mechanism or combination of mechanisms that are most convenient. See Section 1, “ Persistent Class List ” for a discussion of when it is necessary to list your persistent classes.

  • Types: A semicolon-separated list of fully-qualified persistent class names.

  • Resources: A semicolon-separated list of resource paths to metadata files or jar archives. Each jar archive will be scanned for annotated JPA entities.

  • URLs: A semicolon-separated list of URLs of metadata files or jar archives. Each jar archive will be scanned for annotated JPA entities.

  • ClasspathScan: A semicolon-separated list of directories or jar archives listed in your classpath. Each directory and jar archive will be scanned for annotated JPA entities.

Example 6.1.  Setting a Standard Metadata Factory

<property name="openjpa.MetaDataFactory" value="jpa(ClasspathScan=build;lib.jar)"/>

Example 6.2.  Setting a Custom Metadata Factory

<property name="openjpa.MetaDataFactory" value="com.xyz.CustomMetaDataFactory"/>