Package org.apache.cayenne.map
Class EntityResolver
java.lang.Object
org.apache.cayenne.map.EntityResolver
- All Implemented Interfaces:
Serializable
,MappingNamespace
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:
-
Field Summary
Modifier and TypeFieldDescriptionprotected LifecycleCallbackRegistry
protected ClassDescriptorMap
protected EntityResolver
protected EntitySorter
protected static AtomicLong
protected static final Map
<LifecycleEvent, Class<? extends Annotation>> protected static final org.slf4j.Logger
protected MappingNamespace
protected Collection
<DataMap> protected ValueComparisonStrategyFactory
protected ValueObjectTypeRegistry
-
Constructor Summary
ConstructorDescriptionCreates new empty EntityResolver.EntityResolver
(Collection<DataMap> dataMaps) Creates new EntityResolver that indexes a collection of DataMaps. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataMap
(DataMap map) void
Updates missing mapping artifacts that can be guessed from other mapping information.Returns aLifecycleCallbackRegistry
for handling callbacks.getClassDescriptor
(String entityName) Returns ClassDescriptor for the ObjEntity matching the name.Returns an object that compiles and storesClassDescriptor
instances for all entities.Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier.getDataMap
(String mapName) Returns a DataMap matching the name.Returns an unmodifiable collection of DataMaps.Returns all DbEntities.getDbEntity
(String name) Returns DbEntity for a given name, or null if no such DbEntity is found in the MappingNamespace.getEmbeddable
(String className) Returns anEmbeddable
matching class name or null if such Embeddable is not mapped.getInheritanceTree
(String entityName) Returns all ObjEntities in the namespace.getObjEntity
(Class<?> entityClass) Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified classgetObjEntity
(Class<?> entityClass, boolean lookupClientResolver) Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class, with option to fallback to search by name with client resolver in case entity not found.getObjEntity
(String name) Returns ObjEntity for a given name, or null if no such ObjEntity is found in the MappingNamespace.getObjEntity
(Persistent object) getProcedure
(String procedureName) Returns Procedure for a given name, or null if no such Procedure is found in the MappingNamespace.Returns all Procedures in the namespace.getQueryDescriptor
(String name) Returns a named query or null if no query exists for a given name.Returns all Queries in the namespace.Returns a named result set mapping.void
Refreshes entity cache to reflect the current state of the DataMaps in the EntityResolver.void
removeDataMap
(DataMap map) void
setCallbackRegistry
(LifecycleCallbackRegistry callbackRegistry) Sets a lifecycle callbacks registry of the EntityResolver.void
setDataMaps
(Collection<DataMap> maps) void
setEntitySorter
(EntitySorter entitySorter) void
setValueComparisionStrategyFactory
(ValueComparisonStrategyFactory valueComparisonStrategyFactory) void
setValueObjectTypeRegistry
(ValueObjectTypeRegistry valueObjectTypeRegistry)
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
incrementer
-
LIFECYCLE_EVENT_MAP
-
maps
-
mappingCache
-
clientEntityResolver
-
classDescriptorMap
-
callbackRegistry
-
valueObjectTypeRegistry
-
valueComparisonStrategyFactory
- Since:
- 4.2
-
entitySorter
- Since:
- 4.2
-
-
Constructor Details
-
EntityResolver
public EntityResolver()Creates new empty EntityResolver. -
EntityResolver
Creates new EntityResolver that indexes a collection of DataMaps.
-
-
Method Details
-
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
-
getCallbackRegistry
Returns aLifecycleCallbackRegistry
for handling callbacks. Registry is lazily initialized on first call.- Since:
- 3.0
-
setCallbackRegistry
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
Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier.- Since:
- 1.2
-
getDbEntities
Returns all DbEntities.- Specified by:
getDbEntities
in interfaceMappingNamespace
-
getObjEntities
Description copied from interface:MappingNamespace
Returns all ObjEntities in the namespace.- Specified by:
getObjEntities
in interfaceMappingNamespace
-
getEmbeddables
- Specified by:
getEmbeddables
in interfaceMappingNamespace
- Since:
- 3.0
-
getResults
- Specified by:
getResults
in interfaceMappingNamespace
- Since:
- 4.0
-
getProcedures
Description copied from interface:MappingNamespace
Returns all Procedures in the namespace.- Specified by:
getProcedures
in interfaceMappingNamespace
-
getQueryDescriptors
Description copied from interface:MappingNamespace
Returns all Queries in the namespace.- Specified by:
getQueryDescriptors
in interfaceMappingNamespace
-
getDbEntity
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 interfaceMappingNamespace
-
getObjEntity
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 interfaceMappingNamespace
-
getProcedure
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 interfaceMappingNamespace
-
getQueryDescriptor
Returns a named query or null if no query exists for a given name.- Specified by:
getQueryDescriptor
in interfaceMappingNamespace
-
getEmbeddable
Description copied from interface:MappingNamespace
Returns anEmbeddable
matching class name or null if such Embeddable is not mapped.- Specified by:
getEmbeddable
in interfaceMappingNamespace
- Since:
- 3.0
-
getResult
Description copied from interface:MappingNamespace
Returns a named result set mapping.- Specified by:
getResult
in interfaceMappingNamespace
- Since:
- 3.0
-
getClassDescriptor
Returns ClassDescriptor for the ObjEntity matching the name. Returns null if no matching entity exists.- Since:
- 1.2
-
addDataMap
-
refreshMappingCache
public void refreshMappingCache()Refreshes entity cache to reflect the current state of the DataMaps in the EntityResolver.- Since:
- 4.0
-
getDataMap
Returns a DataMap matching the name. -
setDataMaps
-
getDataMaps
Returns an unmodifiable collection of DataMaps. -
getInheritanceTree
- Specified by:
getInheritanceTree
in interfaceMappingNamespace
- Since:
- 4.0
-
getObjEntity
Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class- Specified by:
getObjEntity
in interfaceMappingNamespace
- Returns:
- the required ObjEntity or null if there is none that matches the specifier
- Since:
- 4.0
-
getObjEntity
Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class, with option to fallback to search by name with client resolver in case entity not found.
This method can be used where entity class can be received from client.
- Parameters:
entityClass
- entity class to searchlookupClientResolver
- flag to fallback to client resolver- Returns:
- the required ObjEntity or null if there is none that matches the specifier
- Since:
- 4.0
-
getObjEntity
- Specified by:
getObjEntity
in interfaceMappingNamespace
-
removeDataMap
-
getClassDescriptorMap
Returns an object that compiles and storesClassDescriptor
instances for all entities.- Since:
- 3.0
-
getValueObjectTypeRegistry
-
setValueObjectTypeRegistry
-
setValueComparisionStrategyFactory
public void setValueComparisionStrategyFactory(ValueComparisonStrategyFactory valueComparisonStrategyFactory) - Since:
- 4.2
-
setEntitySorter
- Since:
- 4.2
-
getEntitySorter
- Since:
- 4.2
-