org.apache.cayenne.jpa.conf
Class EntityMapLoader

java.lang.Object
  extended by org.apache.cayenne.jpa.conf.EntityMapLoader

public class EntityMapLoader
extends Object

Loads JPA mapping information from all sources per JPA specification.

Specification Documentation, Chapter 6.2.1.6

The set of managed persistence classes that are managed by a persistence unit is defined by using one or more of the following:

The result is undefined if multiple mapping files (including any orm.xml file) referenced within a single persistence unit contain overlapping mapping information for any given class.

The resulting set of entities managed by the persistence unit [and contained in the returned entity map] is the union of these sources, with the mapping metadata annotations (or annotation defaults) for any given class being overridden by the XML mapping information file if there are both annotations as well as XML mappings for that class. The minimum portable level of overriding is at the level of the persistent field or property.

Author:
Andrus Adamchik

Field Summary
protected  EntityMapLoaderContext context
           
protected  Map<String,JpaClassDescriptor> descriptors
           
 
Constructor Summary
EntityMapLoader(PersistenceUnitInfo persistenceUnit)
          Creates an EntityMapLoader for the persistence unit, merging entity information from all locations supported by the JPA specification.
 
Method Summary
 EntityMapLoaderContext getContext()
           
 JpaEntityMap getEntityMap()
          Returns an entity map with entity
protected  void loadEntityMap(PersistenceUnitInfo persistenceUnit)
          Loads a combined entity map including managed class descriptors from all supported locations.
protected  void loadFromAnnotations(PersistenceUnitInfo persistenceUnit)
          Loads JpaEntityMap based on metadata annotations of persistent classes.
protected  void updateFromDefaults()
          Updates missing values with spec-compilant defaults.
protected  void updateFromXML(PersistenceUnitInfo unit)
          Updates mapping with data loaded from XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected EntityMapLoaderContext context

descriptors

protected Map<String,JpaClassDescriptor> descriptors
Constructor Detail

EntityMapLoader

public EntityMapLoader(PersistenceUnitInfo persistenceUnit)
Creates an EntityMapLoader for the persistence unit, merging entity information from all locations supported by the JPA specification.

Method Detail

getEntityMap

public JpaEntityMap getEntityMap()
Returns an entity map with entity


loadEntityMap

protected void loadEntityMap(PersistenceUnitInfo persistenceUnit)
                      throws JpaProviderException
Loads a combined entity map including managed class descriptors from all supported locations.

Throws:
JpaProviderException

updateFromDefaults

protected void updateFromDefaults()
Updates missing values with spec-compilant defaults.


updateFromXML

protected void updateFromXML(PersistenceUnitInfo unit)
                      throws IOException
Updates mapping with data loaded from XML. JPA specification gives some leeway in processing conflicting mapping files. Cayenne provider strategy is "last mapping file overrides all".

Specification Documentation, Chapter 6.2.1.6

An orm.xml file may be specified in the META-INF directory in the root of the persistence unit or in the META-INF directory of any jar file referenced by the persistence.xml. Alternatively, or in addition, other mapping files maybe referenced by the mapping-file elements of the persistence-unit element, and may be present anywhere on the classpath. An orm.xml file or other mapping file is loaded as a resource by the persistence provider.

Throws:
IOException

loadFromAnnotations

protected void loadFromAnnotations(PersistenceUnitInfo persistenceUnit)
Loads JpaEntityMap based on metadata annotations of persistent classes.


getContext

public EntityMapLoaderContext getContext()


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.