Chapter 22.  Metadata

Table of Contents

Metadata Factory
Metadata Repository
Additional JPA Metadata
Datastore Identity
Surrogate Version
Persistent Field Values
Persistent Collection Fields
Persistent Map Fields
Metadata Extensions
Class Extensions
Field Extensions
Example

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

Metadata Factory

The openjpa.MetaDataFactory configuration property controls metadata loading and storing. This property takes a plugin string (see the section called “ 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 the section called “ 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 the section called “ 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 22.1.  Setting a Standard Metadata Factory

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

Example 22.2.  Setting a Custom Metadata Factory

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