Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/sandbox/gelernter/Extensible Domain Models"

m
m
Line 54: Line 54:
 
An extended entity stores extended attributes in a <tt>Map</tt>, and values from the <tt>Map</tt> are mapped to the database using an <tt>eclipselink-orm.xml</tt> mapping file.  
 
An extended entity stores extended attributes in a <tt>Map</tt>, and values from the <tt>Map</tt> are mapped to the database using an <tt>eclipselink-orm.xml</tt> mapping file.  
  
An extensible entity class must have a <tt>get</tt> method that returns a value by property name and a <tt>set</tt> method that stores a value by property name. The default names for these methods are <tt>get</tt> and <tt>set</tt>, and they can be overridden with the <tt>@VirtualAccessMethods</tt> annotation.  
+
An extensible entity class must have a <tt>get()</tt> method that returns a value by property name and a <tt>set()</tt> method that stores a value by property name. The default names for these methods are <tt>get()</tt> and <tt>set()</tt>, and they can be overridden with the <tt>@VirtualAccessMethods</tt> annotation.  
  
EclipseLink weaves these methods if weaving is enabled, which provides support for lazy loading, change tracking, fetch groups, and internal optimizations.
+
EclipseLink weaves these methods if weaving is enabled, which provides support for lazy loading, change tracking, fetch groups, and internal optimizations.  
 +
 
 +
{{EclipseLink_Note
 +
|note=Weaving is not supported when using virtual access methods with OneToOne mappings. If attempted, an exception will be thrown.
 +
}}
  
 
Use the <tt>@Transient</tt> annotation to prevent the entity from being mapped as an inheritance relationship.  
 
Use the <tt>@Transient</tt> annotation to prevent the entity from being mapped as an inheritance relationship.  
Line 96: Line 100:
 
**VARCHAR FLEX_CO31  
 
**VARCHAR FLEX_CO31  
  
You can then specify which of those flex columns should be used to persist an extended attribute, as described below, in [[Providing Additional Mappings| Providing Additional Mappings]].
+
You can then specify which of those flex columns should be used to persist an extended attribute, as described below, in [[#Providing Additional Mappings| Providing Additional Mappings]].
 
===Providing Additional Mappings===
 
===Providing Additional Mappings===
  
Line 128: Line 132:
 
*Field access is used for non-extension fields.
 
*Field access is used for non-extension fields.
 
*Virtual access is used for extension fields, using defaults <tt>(get(String)</tt> and <tt>set(String, Object)) </tt>  
 
*Virtual access is used for extension fields, using defaults <tt>(get(String)</tt> and <tt>set(String, Object)) </tt>  
*The get(String) and set(String, Object) methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt> <br>
+
*The <tt>get(String)</tt> and <tt>set(String, Object)</tt> methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt> <br>
 
'''''// REVIEWERS: All the examples make this point, but I don't see @Extensible used elsewhere in this spec, in the Javadoc, in the sample on available from Samples area, and I don't see <extensible> in eclipselink-orm.xsd. Does it exist? If it does not exist, should this bullet be rewritten to say something new about weaving, or should I delete it?//'''''
 
'''''// REVIEWERS: All the examples make this point, but I don't see @Extensible used elsewhere in this spec, in the Javadoc, in the sample on available from Samples area, and I don't see <extensible> in eclipselink-orm.xsd. Does it exist? If it does not exist, should this bullet be rewritten to say something new about weaving, or should I delete it?//'''''
 
*Extensions are mapped in a portable way by specifying <tt>@Transient</tt>.  
 
*Extensions are mapped in a portable way by specifying <tt>@Transient</tt>.  
Line 167: Line 171:
  
 
*Field access is used for non-extension fields.
 
*Field access is used for non-extension fields.
* Extensions mapped in a portable way - <tt>@Transient</tt>
 
 
* The <tt>@VirtualAccessMethods</tt> annotation overrides methods to be used for getting and setting.  
 
* The <tt>@VirtualAccessMethods</tt> annotation overrides methods to be used for getting and setting.  
 
* The <tt>getExtension(String)</tt> and <tt>setExtension(String, Object)</tt> methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt> << I don't see @Extensible
 
* The <tt>getExtension(String)</tt> and <tt>setExtension(String, Object)</tt> methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt> << I don't see @Extensible
* The XML for extended mapping indicates which get and set method to use .
+
*Extensions are mapped in a portable way by specifying <tt>@Transient</tt>.
 +
'''''// REVIEWERS: See my in example 1?//'''''
 +
* The XML for extended mapping indicates which <tt>get()</tt> and <tt>set()</tt> method to use.
  
  
Line 213: Line 218:
 
Example 3  illustrates the following:  
 
Example 3  illustrates the following:  
  
* Property Access for non extension fields  
+
* Property access is used for non extension fields.
* Virtual Access for extension fields uses defaults <tt>(get(String), set(String, Object))</tt>  
+
*Virtual access is used for extension fields, using defaults <tt>(get(String)</tt> and <tt>set(String, Object)) </tt>  
* The extensions are mapped in a portable way; no @Transient is required because of Property access  
+
* The extensions are mapped in a portable way; no @Transient is required because property access is used.
 +
'''''//REVIEWERS: Why? See also my comments on @Transient in example 1//'''''
 
* The <tt>get(String)</tt> and <tt>set(String, Object) </tt> methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt>  
 
* The <tt>get(String)</tt> and <tt>set(String, Object) </tt> methods will be woven, even if no mappings use them, because of the presence of <tt>@Extensible</tt>  
 +
'''''//REVIEWERS: See also comments about <tt>@Extensible</tt> in example 1//'''''
  
 
<source lang="java">
 
<source lang="java">
Line 243: Line 250:
 
</source>
 
</source>
  
===EntityManagerFactory and Metadata Repository ===
+
==Configuring the EntityManagerFactory and the Metadata Repository ==
  
Extensions will be added at bootstrap time through access to a metadata repository. A Metadata Repository will accessed through a class that provides methods to retrieve the metadata it holds.  
+
'''''//I'm not sure about this section. Is this really mostly implementation details whose user-facing information is already discussed above? Or should we retain this section to delve deeper into these subjects? If so, please advise what to say here.//'''''
  
The user will specifiy the class to use and any configuration information for the metadata repository through persistence unit properties. As an EntityManagerFactory bootstraps, if metadata repository information is provided, the EMF will check the metadata repository for additional mapping information and integrate it into the metadata it uses to bootstrap.
+
Extensions are added at bootstrap time through access to a metadata repository. The metadata repository is accessed through a class that provides methods to retrieve the metadata it holds.  
EclipseLink will initially ship with the capability of connecting to two types of metadata repository.  
+
  
XML (high priority) - information about extensions is stored in XML
+
Specify the class to use and any configuration information for the metadata repository through persistence unit properties. The entity manager factory checks the metadata repository while bootstrapping for additional mapping information. If additional mapping information is found, the entity manager factory integrates the into the metadata it uses to bootstrap.  
Database Table (medium priority) - information about extensions is stored in a database table
+
Additionally, the user will be able to provide an implementation of the class that access the metadata repository.  
+
Each metadata repository access class will specify an individual set of properties to use to connect to the repository
+
Examples
+
XML File
+
+
<source lang="xml">
+
<property name="eclipselink.metadata-source" value="XML"/>
+
  <property name="eclipselink.metadata-source.xml.url" value="foo://bar"/>
+
</source>
+
  
User-Specified
+
Two types of metadata repository are supported: XML and database.
  
<source lang="xml">
+
You can provide your own implementation of the class to access the metadata repository.
<property name="eclipselink.metadata-source" value="com.foo.MetadataRepository"/>
+
Each metadata repository access class must specify an individual set of properties to use to connect to the repository.
  <property name="com.foo.MetadataRepository.location" value="foo://bar"/>
+
'''''//REVIEWERS: Should we provide an example here?//'''''
  <property name="com.foo.MetadataRepository.extra-data" value="foo-bar"/>
+
</source>
+
  
Note: The implementer of <tt>com.foo.MetadataRepository</tt> will be free to choose the properties that their implementation requires.
+
===Examples ===
==Design ==
+
'''''//REVIEWERS: Can we say something more about these examples to explain them? What? And should all this information be moved up to [[#Configuring persitence.xml} Configuring persitence.xml ]]?}//'''''
====Configuration ====
+
Please use the examples above as a guideline configuration XML and annotations. Note that the configuration options to allow a mapping to use VIRTUAL access have been available in EclipseLink for several releases. We will be using those configuration options as they exist and any changes to those will be handled as bugs rather than through this design document.  
+
====Weaving ====
+
The intial VIRTUAL access feature did not include weaving of the get and set methods. As part of the extensions feature will will add weaving of get and set methods that use virtual access. The initial implementation will not support OneToOne mappings and throw an exception at Transformer construction time if weaving is requested for a VIRTUAL mapping that is OneToOne.  
+
  
Get method
+
====XML File Example====
 
+
Original
+
<source lang="java">
+
public <T> T get(String name) {
+
        return (T) getExtensions().get(name);
+
    }
+
</source>
+
Weaved
+
<source lang="java">
+
public Object get(String name)
+
    {
+
        _persistence_checkFetched(name);
+
        return getExtensions().get(name);
+
    }
+
</source>
+
 
+
Set method
+
Original
+
<source lang="java">
+
public Object set(String name, Object value)
+
    {
+
        return getExtensions().put(name, value);
+
 
+
    }
+
</source>
+
Weaved
+
<source lang="java">
+
public Object set(String name, Object value)
+
    {
+
        Object obj = null;
+
        if(_persistence_listener != null)
+
        {
+
            obj = get(name);
+
        } else
+
        {
+
            _persistence_checkFetchedForSet(name);
+
        }
+
        _persistence_propertyChange(name, obj, value);
+
        return getExtensions().put(name, value);
+
    }
+
</source>
+
 
+
To allow weaving, RelationalDescriptor will have a list virtual methods added. This list will be used at transformer-construction time to allow EclipseLink to know which methods it should weave.
+
 
+
<source lang="java">
+
 
+
/** The methods that are used by virtual attributes as getter methods and setter methods. 
+
    * These will be used by our weaver to properly weave those methods
+
    **/
+
    protected List<VirtualAccessMethods> virtualMethods = null;
+
</source>
+
 
+
===EntityManagerFactory ===
+
 
+
====Bootstrap ====
+
 
+
<tt>EntityManagerFactory</tt> bootstrapping occurs within <tt>EntityManagerSetupImpl</tt>. In the <tt>predeploy</tt> method, there is code that obtains the orm.xml files that contain metadata. At that point, the metadata repository will be consulted. It will provide additional metadata information in the same format as is obtained from the orm.xml file.
+
 
+
=== Refresh ===
+
 
+
A mechanism will be provided that allows a user to tell a Metadata repository to refresh. That mechanism will take two forms.
+
A direct refresh API call
+
A RemoteCommandManager command that causes all subscribed EntityManagerFactories to refresh themselves as described above.
+
Refresh will be supported by adding an additional proxy to our EntityManagerFactory archtecture.
+
Current: EntityManagerFactoryImpl -> ServerSession
+
New: EntityManagerFactoryWrapper implements EntityManagerFactory -> EntityManagerFactoryImpl -> ServerSession
+
EntityManagerFactoryWrapper will implement:
+
public void refreshMetadata()
+
In both cases, a live EntityManager holds a reference to EntityManagerFactoryImpl
+
When a call is made to refreshMetadata(), EntityManagerFactoryWrapper will bootstrap a new EntityManagerFactoryImpl and use it as the basis for any new EntityManagers. The old EntityManagerFactoryImpl will continue to be available until the last EntityManager is no longer used, at which point we will rely on garbage collection to clean it up.
+
Metadata Source
+
An implementation of MetadataSoruce will access metadata for extensions. Metadata is accessed in the form of an eclipselink-orm.xml file.
+
 
+
 
+
<source lang="xml">
+
package org.eclipse.persistence.jpa.metadata;
+
 
   
 
   
public interface MetadataSource{
 
 
    /**
 
    * ADVANCED:
 
    * In most cases, this method should not be overridden.  The implementation of
 
    * this method uses getEntityMappingsReader() to obtain a reader that will
 
    * that reads a stream in the eclipselink-orm.xml format
 
    * Advanced implementations of MetadataRepository have to option of overriding
 
    * this method.
 
    * @return XMLEntityMappings which are then merged in using existing metadata
 
    * processing at bootstrap time when creating an entityManager
 
    */
 
</source>
 
 
 
<source lang="xml">
 
<source lang="xml">
 
+
<property name="eclipselink.metadata-source" value="XML"/>
    public XMLEntityMappings getMetadata(Properties properties, ClassLoader loader)
+
<property name="eclipselink.metadata-source.xml.url" value="foo://bar"/>
 
+
 
</source>
 
</source>
  
Additionally, an adapter class will be provided that implements <tt>MetadataSource</tt> containing stubbed-out methods. You should implement a <tt>MetadataSource</tt> by subclassing the adapter class rather than directly implementing the interface. This strategy will allows you to transparently absorb any new versions of the interface in new EclipseLink versions.
 
  
===XMLMetadataSource ===
+
====User-Specified Example====
 
+
The first implementation of MetadataSource provided by EclipseLink will access a simple XML file. It will provide an implementation of getMetadata(properties, classlaoder) that uses the property "eclipselink.metadata-repository.xml-file.url", specified like this:
+
  
 
<source lang="xml">
 
<source lang="xml">
<property name="eclipselink.metadata-source.xml.url" value="foo://bar"/>
+
<property name="eclipselink.metadata-source" value="com.foo.MetadataRepository"/>
 +
<property name="com.foo.MetadataRepository.location" value="foo://bar"/>
 +
<property name="com.foo.MetadataRepository.extra-data" value="foo-bar"/>
 
</source>
 
</source>
  
To create an input stream on the eclipselink-orm.xml file at URL: "foo://bar"/" and build an XMLEntityMappings using our existing EclipseLink ORM parsing code.
+
{{EclipseLink_Note
Writing to a metadata repository
+
note=Use [[www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/jpa/JpaEntityManagerFactory.html#refreshMetadata(java.util.Map) |RefreshMetadata()]] to refresh the metadata repository.
In the initial implementation writing to the metadata repository will be left up to the user.
+
}}
Remote Command Manager
+
{{EclipseLink_JPA
A Command for RemoteCommandManager will be implemented that triggers a refreshMetadata() call on all subscribed EntityManagerFactories.
+
|previous=[[]]
Design is in progress and will be added as it becomes available
+
|next=    [[]]
Future Enhancements
+
|up=     [[]]
Weaving of OneToOne mappings
+
| }}
Implement support for weaving of non-basic VIRTUAL mappings
+
Handle OneToOneMappings
+
Handle indirection
+
Allow metadata to be updated with an in-memory structure
+
From GlassFish team:
+
Programmatic API to call into EclipseLink to "push" the extension definitions.
+
The data exchanged between the caller and EclipseLink via API should be in a format that just refers to extension information and not a generic data structure.
+
The API call should be on an EclipseLink artifact that does not trigger deploy. That is it should be on an artifact at EMF level.
+
Database Metadata Source
+
Provide an implementation of Metadata Source that reads from a database.
+
Writing to a metadata Source
+
Provide API to write to the XMLFile and DatabaseMetadata Sources.
+
Configuration of muliple getter and setter methods
+
Allow annotations and xml to specify a list of methods for VIRTUAL mappings to weave
+
Appendices
+
Appendix 1: Alternatives Considered
+
http://wiki.eclipse.org/EclipseLink/DesignDocs/335601
+
Appendix 2: Annotations
+
<source lang="java">
+
/**
+
* Specifies that this class contains virtual attributes.
+
* This annotation is used in an EclipseLink-specific way to define
+
* access methods used by mappings with accessType=VIRTUAL.
+
* The xml-equivalent is the <access-methods> tag
+
*/
+
@Documented
+
@Target(TYPE)
+
@Retention(RUNTIME)
+
public @interface VirtualAccessMethods {
+
+
    /**
+
    * (Optional) The name of the getter method to use for the virtual property
+
    * This method must take a single java.lang.String parameter and return a java.lang.Object.
+
    * If setMethod is specified, getMethod must be specified
+
    */
+
    String get() default "get";
+
+
    /**
+
     * (Optional) The name of the setter method to use for the virtual property
+
    * This method must take a java.lang.String parameter and a java.lang.Object parameter.
+
    * If getMethod is specified, setMethod must be specified
+
    */
+
    String set() default "set";
+
}
+
</source>
+

Revision as of 09:43, 27 June 2011

EclipseLink JPA

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

Extensible Entities

This feature is new in EclipseLink 2.3.

Use the @VirtualAccessMethods annotation to specify that an entity is extensible. By using virtual properties in the entity, you can specify mappings external to the entity. This allows you to modify the mappings without modifying the entity source file and without redeploying the entity's persistence unit.

Extensible entities are useful in a multi-tenant (or Software-as-a-Service) environment where a shared, generic application can used by multiple clients (tenants), and each tenant can have access to their own, private data, as well as to data shared with other tenants.

Using extended entities, you can:

  • Build an application where some mappings are common to all users and some mappings are user-specific.
  • Add mappings to an application after it is made available to a customer (even post-deployment).
  • Use the same EntityManagerFactory to work with data after mappings have changed
  • Provide an additional source of metadata to be used by an application.

To extend the entities and take advantage of flexible columns, you must do the following:

  1. Configure the entity with @VirtualAccessMethods to specify that the entity is extensible and to define virtual properties. See Configuring the Entity.
  2. Include flexible columns in the database table to store the additional data. See Designing the Schema.
  3. Specify extended mappings in the eclipselink-orm.xml file. See Providing Additional Mappings
  4. Configure persistence.xml. See Configuring persistence.xml.

Configuring the Entity

Use the @VirtualAccessMethods annotation to specify that an entity allows flexible mappings.

@VirtualAccessMethods Attributes
Attribute Description Default Required?
get The name of the getter method to use for the virtual property This method must take a single java.lang.String parameter and return a java.lang.Object. get No
set The name of the setter method to use for the virtual property This method must take a java.lang.String parameter and return a java.lang.Object parameter. set No

An extended entity stores extended attributes in a Map, and values from the Map are mapped to the database using an eclipselink-orm.xml mapping file.

An extensible entity class must have a get() method that returns a value by property name and a set() method that stores a value by property name. The default names for these methods are get() and set(), and they can be overridden with the @VirtualAccessMethods annotation.

EclipseLink weaves these methods if weaving is enabled, which provides support for lazy loading, change tracking, fetch groups, and internal optimizations.

Elug note icon.png

Note: Weaving is not supported when using virtual access methods with OneToOne mappings. If attempted, an exception will be thrown.

Use the @Transient annotation to prevent the entity from being mapped as an inheritance relationship.

//REVIEWERS: Can that be right? I stole that phrase from the MOXy extensibility sample doc, but my understanding of transient in JPA is that it means a property or field isn't persisted. So what should be said here about transient? Is it required when specifying virtual properties? These issues also come up in the explanations for the examples, below.//

Example

@Entity
  @VirtualAccessMethods
  public class Customer{
 
...
 
    @Transient
    private Map<String, Object> extensions;
 
    public <T> T get(String name) {
        return (T) extentions.get(name);
    }
 
    public Object set(String name, Object value) {
        return extensions.put(name, value);
    }

Designing the Schema

Provide database tables with extra columns for storing store determines how the persistence provider accesses the state of an entity or embedded object.

When you design your schema, provide enough extra columns in the tables to accommodate the number of flexible mappings to allow. For example, the following Customer table that includes two predefined columns, ID and NAME, and three flexible columns, FLEX_COL1, FLEX_COL2, FLEX_COL3:

  • CUSTOMER
    • INTEGER ID
    • VARCHAR NAME
    • VARCHAR FLEX_COL1
    • VARCHAR FLEX_COL2
    • VARCHAR FLEX_CO31

You can then specify which of those flex columns should be used to persist an extended attribute, as described below, in Providing Additional Mappings.

Providing Additional Mappings

To provide additional mappings, add the mappings to the eclipselink-orm.xml file, for example:

<basic name="idNumber" attribute-type="String">
  <column name="FLEX_COL1"/>
  <access-methods get-method="get" set-method="set"/>
</basic>

REVIEWERS: Are there any limitations on the types of mappings that support flexible mappings? Also, do you think anything more should be said about what you have to do in eclipselink-orm.xml?

Configuring persistence.xml

Configure persistence unit properties in persistence.xml to indicate that the application should retrieve the flexible mappings from the eclipselink-orm.xml file,. For example:

“Did I get that intro right? Would different wording be better here? The design doc said “Use persistence unit properties to get your application to use the file:”

<property name="eclipselink.metadata-source" value="XML"/>
<property name="eclipselink.metadata-source.xml.url" value="foo://bar"/>

Examples

The following examples illustrate variations on configuring extensible entities.

Example 1

Example 1 illustrates the following:

  • Field access is used for non-extension fields.
  • Virtual access is used for extension fields, using defaults (get(String) and set(String, Object))
  • The get(String) and set(String, Object) methods will be woven, even if no mappings use them, because of the presence of @Extensible

// REVIEWERS: All the examples make this point, but I don't see @Extensible used elsewhere in this spec, in the Javadoc, in the sample on available from Samples area, and I don't see <extensible> in eclipselink-orm.xsd. Does it exist? If it does not exist, should this bullet be rewritten to say something new about weaving, or should I delete it?//

  • Extensions are mapped in a portable way by specifying @Transient.

// REVIEWERS: See my question earlier about @Transient, under "Configuring the Entity." In short, what should be said here about using @Transient?//


Example 1

@Entity
  @VirtualAccessMethods
  public class Address {
 
    @Id
    private int id;
 
    @Transient
    private Map<String, Object> extensions;
 
    public int getId(){
        return id;
    }
 
    public <T> T get(String name) {
        return (T) extentions.get(name);
    }
 
    public Object set(String name, Object value) {
        return extensions.put(name, value);
    }
 
...

Example 2

Example 2 illustrates the following:

  • Field access is used for non-extension fields.
  • The @VirtualAccessMethods annotation overrides methods to be used for getting and setting.
  • The getExtension(String) and setExtension(String, Object) methods will be woven, even if no mappings use them, because of the presence of @Extensible << I don't see @Extensible
  • Extensions are mapped in a portable way by specifying @Transient.

// REVIEWERS: See my in example 1?//

  • The XML for extended mapping indicates which get() and set() method to use.


Example 2

@Entity
  @VirtualAccessMethods(get="getExtension", set="setExtension")
  public class Address {
 
    @Id
    private int id;
 
    @Transient
    private Map<String, Object> extensions;
 
    public int getId(){
        return id;
    }
 
    public <T> T getExtension(String name) {
        return (T) extensions.get(name);
    }
 
    public Object setExtension(String name, Object value) {
        return extensions.put(name, value);
    }
 
...
<basic name="name" attribute-type="String">
      <column name="FLEX_1"/>
      <access-methods get-method="getExtension" set-method="setExtension"/>
    </basic>

Example 3

Example 3 illustrates the following:

  • Property access is used for non extension fields.
  • Virtual access is used for extension fields, using defaults (get(String) and set(String, Object))
  • The extensions are mapped in a portable way; no @Transient is required because property access is used.

//REVIEWERS: Why? See also my comments on @Transient in example 1//

  • The get(String) and set(String, Object) methods will be woven, even if no mappings use them, because of the presence of @Extensible

//REVIEWERS: See also comments about @Extensible in example 1//

@Entity
  @VirtualAccessMethods
  public class Address {
 
    private int id;
 
    private Map<String, Object> extensions;
 
    @Id
    public int getId(){
        return id;
    }
 
    public <T> T get(String name) {
        return (T) extensions.get(name);
    }
 
    public Object set(String name, Object value) {
        return extensions.put(name, value);
    }
 
...

Configuring the EntityManagerFactory and the Metadata Repository

//I'm not sure about this section. Is this really mostly implementation details whose user-facing information is already discussed above? Or should we retain this section to delve deeper into these subjects? If so, please advise what to say here.//

Extensions are added at bootstrap time through access to a metadata repository. The metadata repository is accessed through a class that provides methods to retrieve the metadata it holds.

Specify the class to use and any configuration information for the metadata repository through persistence unit properties. The entity manager factory checks the metadata repository while bootstrapping for additional mapping information. If additional mapping information is found, the entity manager factory integrates the into the metadata it uses to bootstrap.

Two types of metadata repository are supported: XML and database.

You can provide your own implementation of the class to access the metadata repository. Each metadata repository access class must specify an individual set of properties to use to connect to the repository. //REVIEWERS: Should we provide an example here?//

Examples

//REVIEWERS: Can we say something more about these examples to explain them? What? And should all this information be moved up to [[#Configuring persitence.xml} Configuring persitence.xml ]]?}//

XML File Example

<property name="eclipselink.metadata-source" value="XML"/>
<property name="eclipselink.metadata-source.xml.url" value="foo://bar"/>


User-Specified Example

<property name="eclipselink.metadata-source" value="com.foo.MetadataRepository"/>
<property name="com.foo.MetadataRepository.location" value="foo://bar"/>
<property name="com.foo.MetadataRepository.extra-data" value="foo-bar"/>

{{EclipseLink_Note note=Use RefreshMetadata() to refresh the metadata repository. }}

Eclipselink-logo.gif
Version: DRAFT
Other versions...

Back to the top