Class 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
    • Constructor Detail

      • EntityResolver

        public EntityResolver()
        Creates new empty 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
      • 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
      • 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)
      • refreshMappingCache

        public void refreshMappingCache()
        Refreshes entity cache to reflect the current state of the DataMaps in the EntityResolver.
        Since:
        4.0
      • getDataMap

        public DataMap getDataMap​(String mapName)
        Returns a DataMap matching the name.
      • getDataMaps

        public Collection<DataMap> getDataMaps()
        Returns an unmodifiable collection of DataMaps.
      • getObjEntity

        public ObjEntity getObjEntity​(Class<?> entityClass)
        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 interface MappingNamespace
        Returns:
        the required ObjEntity or null if there is none that matches the specifier
        Since:
        4.0
      • getObjEntity

        public ObjEntity getObjEntity​(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.

        This method can be used where entity class can be received from client.

        Parameters:
        entityClass - entity class to search
        lookupClientResolver - flag to fallback to client resolver
        Returns:
        the required ObjEntity or null if there is none that matches the specifier
        Since:
        4.0
      • removeDataMap

        public void removeDataMap​(DataMap map)
      • getClassDescriptorMap

        public ClassDescriptorMap getClassDescriptorMap()
        Returns an object that compiles and stores ClassDescriptor instances for all entities.
        Since:
        3.0
      • setValueObjectTypeRegistry

        public void setValueObjectTypeRegistry​(ValueObjectTypeRegistry valueObjectTypeRegistry)