EclipseLink Solutions Guide for EclipseLink
Release 2.6
  Go To Table Of Contents

Main Tasks

To use an external metadata source for your mapping information, perform the following tasks:

Task 1: Configure the Persistence Unit

In your persistence unit, specify the external metadata source by defining an eclipselink.metadata.source property and assign as its value a class that implements org.eclipse.persistence.jpa.metadata.MetadataSource. For example:

<property name="eclipselink.metadata-source" value="mypackage.MyMetadataSource"/>

You are free to provide the metadata location in your class as you choose, for example:

public class AdminMetadataSource extends XMLMetadataSource {
    public XMLEntityMappings getEntityMappings(Map<String, Object> properties, ClassLoader classLoader, SessionLog log) {
        String leagueId = (String) properties.get(LEAGUE_CONTEXT);
        properties.put(PersistenceUnitProperties.METADATA_SOURCE_XML_URL, "http://myserverlocation/rest/" + leagueId + "/orm");
        return super.getEntityMappings(properties, classLoader, log);

Task 2: Configure the Server

To access the metadata file, the server must provide URL access to the mapping file by using any of the following:

  • Static file serving

  • A server-based solution with its own mapping file or a mapping file built on-demand from stored mapping information

  • Some other web technology.