Overview | Package | Class | 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:
  java.io.Serializable, MappingNamespace

    public class EntityResolver

extends java.lang.Object
implements MappingNamespace, java.io.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
Author:
  Andrus Adamchik
See Also:
  Serialized Form

Field Summary
`protected ClassDescriptorFactory` | `classDescriptorFactory`
`protected EntityResolver` | `clientEntityResolver`
`protected java.util.Map` | `dbEntityCache`
`protected java.util.Map` | `entityInheritanceCache`
`protected boolean` | `indexedByClass`
`protected java.util.List` | `maps`
`protected java.util.Map` | `objEntityCache`
`protected java.util.Map` | `procedureCache`
`protected java.util.Map` | `queryCache`

Constructor Summary
`EntityResolver()` Creates new EntityResolver.
`EntityResolver(java.util.Collection dataMaps)` Creates new EntityResolver that indexes a collection of DataMaps.

Method Summary
`protected DbEntity` | `_lookupDbEntity(java.lang.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(java.lang.Object object)` 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` | `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.
`ClassDescriptor` | `getClassDescriptor(java.lang.String entityName)` Returns ClassDescriptor for the ObjEntity matching the name.
`ClassDescriptorFactory` | `getClassDescriptorFactory()` Returns a factory for ClassDescriptors used by Cayenne stack.
`EntityResolver` | `getClientEntityResolver()` Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier.
`DataMap` | `getDataMap(java.lang.String mapName)` Returns a DataMap matching the name.
`java.util.Collection` | `getDataMaps()` Returns an unmodifiable collection of DataMaps.
`java.util.Collection` | `getDbEntities()` Returns all DbEntities.
`DbEntity` | `getDbEntity(java.lang.String name)` Returns DbEntity for a given name, or null if no such DbEntity is found in the MappingNamespace.
`java.util.Collection` | `getObjEntities()` Returns all ObjEntities in the namespace.
`ObjEntity` | `getObjEntity(java.lang.String name)` Returns ObjEntity for a given name, or null if no such ObjEntity is found in the MappingNamespace.
`Procedure` | `getProcedure(java.lang.String name)` Returns Procedure for a given name, or null if no such Procedure is found in the MappingNamespace.
`java.util.Collection` | `getProcedures()` Returns all Procedures in the namespace.
`java.util.Collection` | `getQueries()` Returns all Queries in the namespace.
`Query` | `getQuery(java.lang.String name)` Returns Query for a given name, or null if no such Query is found in the MappingNamespace.
`boolean` | `isIndexedByClass()`
`DataMap` | `lookupDataMap(Query q)` Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getDataMap()'.
`DbEntity` | `lookupDbEntity(java.lang.Class aClass)` Looks in the DataMap's that this object was created with for the DbEntity that services the specified class
`DbEntity` | `lookupDbEntity(Persistent dataObject)` Looks in the DataMap's that this object was created with for the DbEntity that services the specified data Object
`DbEntity` | `lookupDbEntity(Query q)` Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getDbEntity()'
`EntityInheritanceTree` | `lookupInheritanceTree(ObjEntity entity)` Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities.
`ObjEntity` | `lookupObjEntity(java.lang.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(Persistent dataObject)` Looks in the DataMap's that this object was created with for the ObjEntity that services the specified data Object
`ObjEntity` | `lookupObjEntity(Query q)` Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getObjEntity()'.
`ObjEntity` | `lookupObjEntity(java.lang.String entityName)` Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the class with the given name
`Procedure` | `lookupProcedure(Query q)`
`Procedure` | `lookupProcedure(java.lang.String procedureName)`
`Query` | `lookupQuery(java.lang.String name)` Returns a named query or null if no query exists for a given name.
`void` | `removeDataMap(DataMap map)`
`void` | `setClassDescriptorFactory(ClassDescriptorFactory descriptorFactory)` Sets a factory for ClassDescriptors used by Cayenne stack.
`void` | `setDataMaps(java.util.Collection maps)`
`void` | `setIndexedByClass(boolean b)`

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

Field Detail

### indexedByClass

    protected boolean indexedByClass

### queryCache

    protected java.util.Map queryCache

### dbEntityCache

    protected java.util.Map dbEntityCache

### objEntityCache

    protected java.util.Map objEntityCache

### procedureCache

    protected java.util.Map procedureCache

### maps

    protected java.util.List maps

### entityInheritanceCache

    protected java.util.Map entityInheritanceCache

### clientEntityResolver

    protected EntityResolver clientEntityResolver

### classDescriptorFactory

    protected transient ClassDescriptorFactory classDescriptorFactory

Constructor Detail

### EntityResolver

    public EntityResolver()

  Creates new EntityResolver.

### EntityResolver

    public EntityResolver(java.util.Collection dataMaps)

  Creates new EntityResolver that indexes a collection of DataMaps.

Method Detail

### getClientEntityResolver

    public EntityResolver getClientEntityResolver()

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

  Since:
    1.2

### getDbEntities

    public java.util.Collection getDbEntities()

  Returns all DbEntities.

  Specified by:
    `getDbEntities` in interface `MappingNamespace`

### getObjEntities

    public java.util.Collection getObjEntities()

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

  Specified by:
    `getObjEntities` in interface `MappingNamespace`

### getProcedures

    public java.util.Collection getProcedures()

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

  Specified by:
    `getProcedures` in interface `MappingNamespace`

### getQueries

    public java.util.Collection getQueries()

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

  Specified by:
    `getQueries` in interface `MappingNamespace`

### getDbEntity

    public DbEntity getDbEntity(java.lang.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(java.lang.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(java.lang.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(java.lang.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`

### getClassDescriptor

    public ClassDescriptor getClassDescriptor(java.lang.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(java.lang.String mapName)

  Returns a DataMap matching the name.

### setDataMaps

    public void setDataMaps(java.util.Collection maps)

### getDataMaps

    public java.util.Collection getDataMaps()

  Returns an unmodifiable collection of DataMaps.

### lookupDataMap

    public DataMap lookupDataMap(Query q)

  Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getDataMap()'.

  Searches for DataMap that holds Query root object.

### lookupDbEntity

    public DbEntity lookupDbEntity(java.lang.Class aClass)

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

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

### lookupDbEntity

    public DbEntity lookupDbEntity(Persistent dataObject)

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

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

### lookupDbEntity

    public DbEntity lookupDbEntity(Query q)

  Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getDbEntity()'

  Looks up the DbEntity for the given query by using the query's getRoot method and passing to lookupDbEntity

  Returns:
    the root DbEntity of the query

### lookupInheritanceTree

    public EntityInheritanceTree lookupInheritanceTree(ObjEntity entity)

  Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities. If ObjEntity has no known subentities, null is returned.

### lookupObjEntity

    public ObjEntity lookupObjEntity(java.lang.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(Persistent dataObject)

  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

### lookupObjEntity

    public ObjEntity lookupObjEntity(Query q)

  Deprecated. since 1.2 use 'Query.getMetaData(EntityResolver).getObjEntity()'.

  Looks up the ObjEntity for the given query by using the query's getRoot method and passing to lookupObjEntity

  Returns:
    the root ObjEntity of the query
  Throws:
    `CayenneRuntimeException` - if the root of the query is a DbEntity (it is not reliably possible to map from a DbEntity to an ObjEntity as a DbEntity may be the source for multiple ObjEntities. It is not safe to rely on such behaviour).

### lookupObjEntity

    public ObjEntity lookupObjEntity(java.lang.String entityName)

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

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

### lookupProcedure

    public Procedure lookupProcedure(Query q)

### lookupProcedure

    public Procedure lookupProcedure(java.lang.String procedureName)

### lookupQuery

    public Query lookupQuery(java.lang.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)

### _lookupDbEntity

    protected DbEntity _lookupDbEntity(java.lang.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(java.lang.Object object)

  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

### getClassDescriptorFactory

    public ClassDescriptorFactory getClassDescriptorFactory()

  Returns a factory for ClassDescriptors used by Cayenne stack. This method is guaranteed to return non null value. If the factory hasn't been set explicitly, it initializes default `EntityDescriptorFactory`.

  Since:
    1.2

### setClassDescriptorFactory

    public void setClassDescriptorFactory(ClassDescriptorFactory descriptorFactory)

  Sets a factory for ClassDescriptors used by Cayenne stack.

  Since:
    1.2

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

Copyright © 2001-2006 Apache.org All Rights Reserved.