Chapter 6.  Metadata

Table of Contents

1. Metadata Factory
2. Additional JPA Metadata
2.1. Datastore Identity
2.2. Surrogate Version
2.3. Persistent Field Values
2.4. Persistent Collection Fields
2.5. Persistent Map Fields
3. Metadata Extensions
3.1. Class Extensions
3.1.1. Fetch Groups
3.1.2. Data Cache
3.1.3. Detached State
3.2. Field Extensions
3.2.1. Dependent
3.2.2. Load Fetch Group
3.2.3. LRS
3.2.4. Inverse-Logical
3.2.5. Read-Only
3.2.6. Type
3.2.7. Externalizer
3.2.8. Factory
3.2.9. External Values
3.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=""/>