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.map
Class EntityResolver

    java.lang.Object
      org.apache.cayenne.map.EntityResolver

All Implemented Interfaces:
  Serializable, MappingNamespace

    public class EntityResolver

extends Object
implements MappingNamespace, Serializable

Represents a virtual shared namespace for zero or more DataMaps. Unlike DataMap, EntityResolver is intended to work as a runtime container of mapping. DataMaps can be added or removed dynamically at runtime.

EntityResolver is thread-safe.

Since:
  1.1
See Also:
  Serialized Form

Field Summary
`protected LifecycleCallbackRegistry` | `callbackRegistry`
`protected ClassDescriptorMap` | `classDescriptorMap`
`protected EntityResolver` | `clientEntityResolver`
`protected Map<String,DbEntity>` | `dbEntityCache`
`protected Map<String,Embeddable>` | `embeddableCache`
`protected Map<String,EntityInheritanceTree>` | `entityInheritanceCache`
`protected EntityListenerFactory` | `entityListenerFactory`
`protected boolean` | `indexedByClass`
`protected static org.apache.commons.logging.Log` | `logger`
`protected Collection<DataMap>` | `maps`
`protected Map<String,ObjEntity>` | `objEntityCache`
`protected Map<String,Procedure>` | `procedureCache`
`protected Map<String,Query>` | `queryCache`
`protected Map<String,SQLResult>` | `resultsCache`

Constructor Summary
`EntityResolver()` Creates new EntityResolver.
`EntityResolver(Collection<DataMap> dataMaps)` Creates new EntityResolver that indexes a collection of DataMaps.

Method Summary
`protected DbEntity` | `_lookupDbEntity(Object object)` Internal usage only - provides the type-unsafe implementation which services the four typesafe public lookupDbEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object.
`protected ObjEntity` | `_lookupObjEntity(String key)` Internal usage only - provides the type-unsafe implementation which services the three typesafe public lookupObjEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object.
`void` | `addDataMap(DataMap map)`
`void` | `applyDBLayerDefaults()` Updates missing mapping artifacts that can be guessed from other mapping information.
`void` | `applyObjectLayerDefaults()` Updates missing mapping artifacts that can be guessed from other mapping information.
`protected String` | `classKey(String className)` Generates a map key for the object class.
`void` | `clearCache()` Removes all entity mappings from the cache.
`protected void` | `constructCache()` Creates caches of DbEntities by ObjEntity, DataObject class, and ObjEntity name using internal list of maps.
`LifecycleCallbackRegistry` | `getCallbackRegistry()` Returns a `LifecycleCallbackRegistry` for handling callbacks.
`ClassDescriptor` | `getClassDescriptor(String entityName)` Returns ClassDescriptor for the ObjEntity matching the name.
`ClassDescriptorMap` | `getClassDescriptorMap()` Returns an object that compiles and stores `ClassDescriptor` instances for all entities.
`EntityResolver` | `getClientEntityResolver()` Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier.
`DataMap` | `getDataMap(String mapName)` Returns a DataMap matching the name.
`Collection<DataMap>` | `getDataMaps()` Returns an unmodifiable collection of DataMaps.
`Collection<DbEntity>` | `getDbEntities()` Returns all DbEntities.
`DbEntity` | `getDbEntity(String name)` Returns DbEntity for a given name, or null if no such DbEntity is found in the MappingNamespace.
`Embeddable` | `getEmbeddable(String className)` Returns an `Embeddable` matching class name or null if such Embeddable is not mapped.
`Collection<Embeddable>` | `getEmbeddables()`
`Collection<ObjEntity>` | `getObjEntities()` Returns all ObjEntities in the namespace.
`ObjEntity` | `getObjEntity(String name)` Returns ObjEntity for a given name, or null if no such ObjEntity is found in the MappingNamespace.
`Procedure` | `getProcedure(String name)` Returns Procedure for a given name, or null if no such Procedure is found in the MappingNamespace.
`Collection<Procedure>` | `getProcedures()` Returns all Procedures in the namespace.
`Collection<Query>` | `getQueries()` Returns all Queries in the namespace.
`Query` | `getQuery(String name)` Returns Query for a given name, or null if no such Query is found in the MappingNamespace.
`SQLResult` | `getResult(String name)` Returns a named result set mapping.
`Collection<SQLResult>` | `getResultSets()`
`boolean` | `isIndexedByClass()`
`EntityInheritanceTree` | `lookupInheritanceTree(ObjEntity entity)` Deprecated. since 3.1 use `lookupInheritanceTree(String)`.
`EntityInheritanceTree` | `lookupInheritanceTree(String entityName)` Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities.
`ObjEntity` | `lookupObjEntity(Class<?> aClass)` Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class
`ObjEntity` | `lookupObjEntity(Object object)` Looks in the DataMap's that this object was created with for the ObjEntity that services the specified data Object
`Procedure` | `lookupProcedure(Query q)`
`Procedure` | `lookupProcedure(String procedureName)`
`Query` | `lookupQuery(String name)` Returns a named query or null if no query exists for a given name.
`void` | `removeDataMap(DataMap map)`
`void` | `setCallbackRegistry(LifecycleCallbackRegistry callbackRegistry)` Sets a lifecycle callbacks registry of the EntityResolver.
`void` | `setDataMaps(Collection<DataMap> maps)`
`void` | `setEntityListenerFactory(EntityListenerFactory entityListenerFactory)` Sets an optional `EntityListenerFactory` that should be used to create entity listeners.
`void` | `setIndexedByClass(boolean b)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected static final org.apache.commons.logging.Log logger

### indexedByClass

    protected boolean indexedByClass

### maps

    protected Collection<DataMap> maps

### queryCache

    protected transient Map<String,Query> queryCache

### embeddableCache

    protected transient Map<String,Embeddable> embeddableCache

### resultsCache

    protected transient Map<String,SQLResult> resultsCache

### dbEntityCache

    protected transient Map<String,DbEntity> dbEntityCache

### objEntityCache

    protected transient Map<String,ObjEntity> objEntityCache

### procedureCache

    protected transient Map<String,Procedure> procedureCache

### entityInheritanceCache

    protected transient Map<String,EntityInheritanceTree> entityInheritanceCache

### clientEntityResolver

    protected EntityResolver clientEntityResolver

### classDescriptorMap

    protected transient ClassDescriptorMap classDescriptorMap

### callbackRegistry

    protected transient LifecycleCallbackRegistry callbackRegistry

### entityListenerFactory

    protected EntityListenerFactory entityListenerFactory

Constructor Detail

### EntityResolver

    public EntityResolver()

  Creates new EntityResolver.

### EntityResolver

    public EntityResolver(Collection<DataMap> dataMaps)

  Creates new EntityResolver that indexes a collection of DataMaps.

Method Detail

### applyDBLayerDefaults

    public void applyDBLayerDefaults()

  Updates missing mapping artifacts that can be guessed from other mapping information. This implementation creates missing reverse relationships, marking newly created relationships as "runtime".

  Since:
    3.0

### applyObjectLayerDefaults

    public void applyObjectLayerDefaults()

  Updates missing mapping artifacts that can be guessed from other mapping information. This implementation creates missing reverse relationships, marking newly created relationships as "runtime".

  Since:
    3.0

### getCallbackRegistry

    public LifecycleCallbackRegistry getCallbackRegistry()

  Returns a `LifecycleCallbackRegistry` for handling callbacks. Registry is lazily initialized on first call.

  Since:
    3.0

### setCallbackRegistry

    public void setCallbackRegistry(LifecycleCallbackRegistry callbackRegistry)

  Sets a lifecycle callbacks registry of the EntityResolver. Users rarely if ever need to call this method as Cayenne would instantiate a registry itself as needed based on mapped configuration.

  Since:
    3.0

### getClientEntityResolver

    public EntityResolver getClientEntityResolver()

  Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier.

  Since:
    1.2

### getDbEntities

    public Collection<DbEntity> getDbEntities()

  Returns all DbEntities.

  Specified by:
    `getDbEntities` in interface `MappingNamespace`

### getObjEntities

    public Collection<ObjEntity> getObjEntities()

  Description copied from interface: `MappingNamespace`
  Returns all ObjEntities in the namespace.

  Specified by:
    `getObjEntities` in interface `MappingNamespace`

### getEmbeddables

    public Collection<Embeddable> getEmbeddables()

  Since:
    3.0

### getResultSets

    public Collection<SQLResult> getResultSets()

  Since:
    3.0

### getProcedures

    public Collection<Procedure> getProcedures()

  Description copied from interface: `MappingNamespace`
  Returns all Procedures in the namespace.

  Specified by:
    `getProcedures` in interface `MappingNamespace`

### getQueries

    public Collection<Query> getQueries()

  Description copied from interface: `MappingNamespace`
  Returns all Queries in the namespace.

  Specified by:
    `getQueries` in interface `MappingNamespace`

### getDbEntity

    public DbEntity getDbEntity(String name)

  Description copied from interface: `MappingNamespace`
  Returns DbEntity for a given name, or null if no such DbEntity is found in the MappingNamespace.

  Specified by:
    `getDbEntity` in interface `MappingNamespace`

### getObjEntity

    public ObjEntity getObjEntity(String name)

  Description copied from interface: `MappingNamespace`
  Returns ObjEntity for a given name, or null if no such ObjEntity is found in the MappingNamespace.

  Specified by:
    `getObjEntity` in interface `MappingNamespace`

### getProcedure

    public Procedure getProcedure(String name)

  Description copied from interface: `MappingNamespace`
  Returns Procedure for a given name, or null if no such Procedure is found in the MappingNamespace.

  Specified by:
    `getProcedure` in interface `MappingNamespace`

### getQuery

    public Query getQuery(String name)

  Description copied from interface: `MappingNamespace`
  Returns Query for a given name, or null if no such Query is found in the MappingNamespace.

  Specified by:
    `getQuery` in interface `MappingNamespace`

### getEmbeddable

    public Embeddable getEmbeddable(String className)

  Description copied from interface: `MappingNamespace`
  Returns an `Embeddable` matching class name or null if such Embeddable is not mapped.

  Specified by:
    `getEmbeddable` in interface `MappingNamespace`
  Since:
    3.0

### getResult

    public SQLResult getResult(String name)

  Description copied from interface: `MappingNamespace`
  Returns a named result set mapping.

  Specified by:
    `getResult` in interface `MappingNamespace`
  Since:
    3.0

### getClassDescriptor

    public ClassDescriptor getClassDescriptor(String entityName)

  Returns ClassDescriptor for the ObjEntity matching the name. Returns null if no matching entity exists.

  Since:
    1.2

### addDataMap

    public void addDataMap(DataMap map)

### clearCache

    public void clearCache()

  Removes all entity mappings from the cache. Cache can be rebuilt either explicitly by calling `constructCache`, or on demand by calling any of the `lookup...` methods.

### constructCache

    protected void constructCache()

  Creates caches of DbEntities by ObjEntity, DataObject class, and ObjEntity name using internal list of maps.

### getDataMap

    public DataMap getDataMap(String mapName)

  Returns a DataMap matching the name.

### setDataMaps

    public void setDataMaps(Collection<DataMap> maps)

### getDataMaps

    public Collection<DataMap> getDataMaps()

  Returns an unmodifiable collection of DataMaps.

### lookupInheritanceTree

    @Deprecated
    public EntityInheritanceTree lookupInheritanceTree(ObjEntity entity)

  Deprecated. since 3.1 use `lookupInheritanceTree(String)`.

  Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities.

### lookupInheritanceTree

    public EntityInheritanceTree lookupInheritanceTree(String entityName)

  Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities. Returns non-null object for all existing entities, even those that don't have super or subclasses.

  Since:
    3.0

### lookupObjEntity

    public ObjEntity lookupObjEntity(Class<?> aClass)

  Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class

  Returns:
    the required ObjEntity or null if there is none that matches the specifier

### lookupObjEntity

    public ObjEntity lookupObjEntity(Object object)

  Looks in the DataMap's that this object was created with for the ObjEntity that services the specified data Object

  Returns:
    the required ObjEntity, or null if none matches the specifier

### lookupProcedure

    public Procedure lookupProcedure(Query q)

### lookupProcedure

    public Procedure lookupProcedure(String procedureName)

### lookupQuery

    public Query lookupQuery(String name)

  Returns a named query or null if no query exists for a given name.

### removeDataMap

    public void removeDataMap(DataMap map)

### isIndexedByClass

    public boolean isIndexedByClass()

### setIndexedByClass

    public void setIndexedByClass(boolean b)

### classKey

    protected String classKey(String className)

  Generates a map key for the object class.

  Since:
    3.0

### _lookupDbEntity

    protected DbEntity _lookupDbEntity(Object object)

  Internal usage only - provides the type-unsafe implementation which services the four typesafe public lookupDbEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object. Object may be a Entity name, ObjEntity, DataObject class (Class object for a class which implements the DataObject interface), or a DataObject instance itself

  Returns:
    the required DbEntity, or null if none matches the specifier

### _lookupObjEntity

    protected ObjEntity _lookupObjEntity(String key)

  Internal usage only - provides the type-unsafe implementation which services the three typesafe public lookupObjEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object. Object may be a Entity name, DataObject instance or DataObject class (Class object for a class which implements the DataObject interface)

  Returns:
    the required ObjEntity or null if there is none that matches the specifier

### getClassDescriptorMap

    public ClassDescriptorMap getClassDescriptorMap()

  Returns an object that compiles and stores `ClassDescriptor` instances for all entities.

  Since:
    3.0

### setEntityListenerFactory

    public void setEntityListenerFactory(EntityListenerFactory entityListenerFactory)

  Sets an optional `EntityListenerFactory` that should be used to create entity listeners. Note that changing the factory does not affect already created listeners. So refresh the existing listners, call "setCallbackRegistry(null)" after setting the listener.

  Since:
    3.0

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-2013 Apache Cayenne. All Rights Reserved.