Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.jpa.conf
Class EntityMapLoader

    java.lang.Object
      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:

- One or more object/relational mapping XML files
- One or more jar files that will be searched for classes
- An explicit list of the classes
- The annotated managed persistence classes contained in the root of the persistence unit (unless the exclude-unlisted-classes element is specified) [Java SE doesn't have to support that].

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(javax.persistence.spi.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 Collection<String>` | `listImplicitClasses(javax.persistence.spi.PersistenceUnitInfo persistenceUnit)` Returns a collection of all classes that are located in the unit root and unit extra jars.
`protected void` | `loadEntityMap(javax.persistence.spi.PersistenceUnitInfo persistenceUnit)` Loads a combined entity map including managed class descriptors from all supported locations.
`protected void` | `loadFromAnnotations(javax.persistence.spi.PersistenceUnitInfo persistenceUnit)` Loads JpaEntityMap based on metadata annotations of persistent classes.
`protected void` | `updateFromDefaults()` Updates missing values with spec-compilant defaults.
`protected void` | `updateFromXML(javax.persistence.spi.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(javax.persistence.spi.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

### getContext

    public EntityMapLoaderContext getContext()

### loadEntityMap

    protected void loadEntityMap(javax.persistence.spi.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(javax.persistence.spi.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(javax.persistence.spi.PersistenceUnitInfo persistenceUnit)

  Loads JpaEntityMap based on metadata annotations of persistent classes.

### listImplicitClasses

    protected Collection<String> listImplicitClasses(javax.persistence.spi.PersistenceUnitInfo persistenceUnit)

  Returns a collection of all classes that are located in the unit root and unit extra jars.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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