Class UnitOfWorkIdentityMapAccessor

  • All Implemented Interfaces:
    Serializable, IdentityMapAccessor

    public class UnitOfWorkIdentityMapAccessor
    extends IdentityMapAccessor
    INTERNAL: IdentityMapAccessor subclass for UnitOfWork Overrides some initialization functionality and some behavior having to do with getting objects from identity maps.
    See Also:
    Serialized Form
    • Constructor Detail

      • UnitOfWorkIdentityMapAccessor

        public UnitOfWorkIdentityMapAccessor()
    • Method Detail

      • getAllFromIdentityMap

        public Vector getAllFromIdentityMap​(Expression selectionCriteria,
                                            Class theClass,
                                            Record translationRow,
                                            int valueHolderPolicy,
                                            boolean shouldReturnInvalidatedObjects)
                                     throws QueryException
        INTERNAL: This method overrides the getAllFromIdentityMap method in Session. Invalidated Objects will always be returned from a UnitOfWork.
        Specified by:
        getAllFromIdentityMap in interface IdentityMapAccessor
        Overrides:
        getAllFromIdentityMap in class IdentityMapAccessor
        Parameters:
        selectionCriteria - Expression selecting the Objects to be returned
        theClass - Class to be considered
        translationRow - Record
        valueHolderPolicy - see InMemoryQueryIndirectionPolicy
        shouldReturnInvalidatedObjects - boolean - true if only invalid Objects should be returned
        Returns:
        Vector of Objects
        Throws:
        QueryException
      • getFromIdentityMapWithDeferredLock

        public Object getFromIdentityMapWithDeferredLock​(Object primaryKey,
                                                         Class theClass,
                                                         boolean shouldReturnInvalidatedObjects,
                                                         ClassDescriptor descriptor)
        INTERNAL: Override the getFromIdentityMapWithDeferredLock method on the session to ensure that invalidated objects are always returned since this is a UnitOfWork
        Overrides:
        getFromIdentityMapWithDeferredLock in class IdentityMapAccessor
      • getFromIdentityMap

        public Object getFromIdentityMap​(Object primaryKey,
                                         Object object,
                                         Class theClass,
                                         boolean shouldReturnInvalidatedObjects,
                                         ClassDescriptor descriptor)
        INTERNAL: Return the object from the identity map with the primary key and class. The parent's cache must be checked after the child's, if found in the parent, it must be registered/cloned (but must avoid looping). Note: in a UnitOfWork, invalidated objects will always be returned from the identity map In the parent session, only return the object if it has not been Invalidated
        Overrides:
        getFromIdentityMap in class IdentityMapAccessor
      • getAndCloneCacheKeyFromParent

        protected Object getAndCloneCacheKeyFromParent​(Object primaryKey,
                                                       Object objectToClone,
                                                       Class theClass,
                                                       boolean shouldReturnInvalidatedObjects,
                                                       ClassDescriptor descriptor)
        INTERNAL: This method will return the object from the parent and clone it.
      • getQueryResult

        public Object getQueryResult​(ReadQuery query,
                                     List parameters,
                                     boolean checkExpiry)
        INTERNAL: Get the cached results associated with a query. Results are cached by the values of the parameters to the query so different parameters will have different cached results. results are only cached in the parent session for UnitOfWorks
        Overrides:
        getQueryResult in class IdentityMapAccessor
      • putQueryResult

        public void putQueryResult​(ReadQuery query,
                                   List parameters,
                                   Object results)
        INTERNAL: Set the results for a query. Query results are cached based on the parameter values provided to the query different parameter values access different caches. Results are only cached in the parent session for UnitOfWorks
        Overrides:
        putQueryResult in class IdentityMapAccessor
      • initializeAllIdentityMaps

        public void initializeAllIdentityMaps()
        INTERNAL: Reset the entire object cache, ** be careful using this. This method blows away both this session's and its parents caches, this includes the server cache or any other cache. This throws away any objects that have been read in. Extreme caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.
        Specified by:
        initializeAllIdentityMaps in interface IdentityMapAccessor
        Overrides:
        initializeAllIdentityMaps in class IdentityMapAccessor
      • checkForInheritance

        protected Object checkForInheritance​(Object domainObject,
                                             Class superClass,
                                             ClassDescriptor descriptor)
        This method is used to resolve the inheritance issues arise while trying to get object from identity map of parent session. Avoid reading the unintended subclass during in-memory query (e.g. when querying on large project, do not want to check small project, both are inherited from the project, and stored in the same identity map).