@Override public boolean containsEntity(EntityManager em, Class<?> entityClass, Object id) { return em.unwrap(JpaEntityManager.class).getActiveSession().getIdentityMapAccessor().getFromIdentityMap(id, entityClass) != null; }
/** * PUBLIC: * Clears the current cached results, the next execution with * read from the database. * */ public void clearQueryResults(AbstractSession session) { session.getIdentityMapAccessor().clearQueryCache(this); }
fromCache = getIdentityMapAccessor().getAllFromIdentityMap(selectionCriteria, referenceClass, arguments, policy); for (Enumeration fromCacheEnum = fromCache.elements(); fromCacheEnum.hasMoreElements();) {
Object deletedObject = deletedObjects.next(); Vector primaryKey = keyFromObject(deletedObject); Object cloneFromParent = getParent().getIdentityMapAccessor().getFromIdentityMap(primaryKey, deletedObject.getClass()); ((UnitOfWorkImpl)getParent()).getIdentityMapAccessor().removeFromIdentityMap(cloneFromParent);
/** * Sets the object to be invalid in the cache. * @see JpaCache#evict(Object) */ public void evict(Object object) { getEntityManagerFactory().verifyOpen(); getAccessor().invalidateObject(object); }
/** * This method is used to initialize the identity maps in the session. */ public synchronized void initializeAllIdentityMaps() { getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); }
/** * INTERNAL: Merge the changes to all objects to the parent. */ protected void mergeChangesIntoParent() { if (this.classesToBeInvalidated != null) { // get identityMap of the parent ServerSession IdentityMapAccessor accessor = this.getParentIdentityMapSession(null, false, true).getIdentityMapAccessor(); Iterator<Class> iterator = this.classesToBeInvalidated.iterator(); while (iterator.hasNext()) { accessor.invalidateClass(iterator.next(), false); } this.classesToBeInvalidated = null; } super.mergeChangesIntoParent(); }
getAccessor().invalidateClass(candidateAssignableDescriptor.getJavaClass()); } else { getAccessor().invalidateObject(createPrimaryKeyFromId(possibleSuperclass, id), candidateAssignableDescriptor.getJavaClass());
/** * ADVANCED: * Resets the cache for only the instances of the given Class type. * For inheritance the user must make sure that they only use the root class, * clearing a subclass cache is not allowed (as they share their parents cache). * <p> NOTE: Caution must be used in doing this to ensure that the Objects within the cache * are not referenced from other Objects of other classes or from the application. */ public void clear(Class cls) { getEntityManagerFactory().verifyOpen(); getAccessor().initializeIdentityMap(cls); }
/** * INTERNAL: * Clear the identityMaps */ private void clearIdentityMapCache() { getIdentityMapAccessor().initializeIdentityMaps(); if (this.parent instanceof IsolatedClientSession) { this.parent.getIdentityMapAccessor().initializeIdentityMaps(); } }
if (descriptor.usesOptimisticLocking()) { cacheKey.setObject(original); cacheKey.setWriteLockValue(unitOfWork.getIdentityMapAccessor().getWriteLockValue(original)); } else {
shouldLoadResultIntoSelectionObject = !((UnitOfWork)session).isObjectRegistered(entity); } else { shouldLoadResultIntoSelectionObject = !session.getIdentityMapAccessor().containsObjectInIdentityMap(entity);
Object clone = clones.get(deletedObject); if (clone == null) { clone = parent.getIdentityMapAccessor().getFromIdentityMap(primaryKey, deletedObject.getClass()); if (clone == null) { clone = deletedObject; parent.getIdentityMapAccessor().removeFromIdentityMap(primaryKey, clone.getClass());
/** * Sets an Object to be invalid in the cache. * If true is passed, the object is also invalidated across cache coordination. * Cache coordination must be enabled for this to have an affect. */ public void evict(Object object, boolean invalidateInCluster) { getEntityManagerFactory().verifyOpen(); getAccessor().invalidateObject(object, invalidateInCluster); }
/** * This method is used to initialize the identity maps in the session. */ public synchronized void initializeAllIdentityMaps() { getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); }
/** * INTERNAL: Merge the changes to all objects to the parent. */ protected void mergeChangesIntoParent() { if (this.classesToBeInvalidated != null) { // get identityMap of the parent ServerSession for(ClassDescriptor classToBeInvalidated : classesToBeInvalidated) { IdentityMapAccessor accessor = this.getParentIdentityMapSession(classToBeInvalidated, false, true).getIdentityMapAccessor(); accessor.invalidateClass(classToBeInvalidated.getJavaClass(), false); // 312503: invalidate subtree rooted at classToBeInvalidated } this.classesToBeInvalidated = null; } super.mergeChangesIntoParent(); }
Object cacheKey = createPrimaryKeyFromId(classToEvict, id); if(null != cacheKey) { getAccessor().invalidateObject(cacheKey, classToEvict, invalidateInCluster); getAccessor().invalidateClass(classToEvict, invalidateRecursively);
/** * This method is used to initialize the identity maps specified by className. * @param className the fully qualified classnames identifying the identity map to initialize */ public synchronized void initializeIdentityMap(String className) throws ClassNotFoundException { Class registeredClass; //get identity map, and initialize registeredClass = (Class)getSession().getDatasourcePlatform().getConversionManager() .convertObject(className, ClassConstants.CLASS); getSession().getIdentityMapAccessor().initializeIdentityMap(registeredClass); ((AbstractSession)session).log(SessionLog.INFO, SessionLog.SERVER, "jmx_mbean_runtime_services_identity_map_initialized", className); }
/** * INTERNAL: * Clear the identityMaps */ private void clearIdentityMapCache() { getIdentityMapAccessor().initializeIdentityMaps(); if (this.parent instanceof IsolatedClientSession) { this.parent.getIdentityMapAccessor().initializeIdentityMaps(); } }
try { if (descriptor.usesOptimisticLocking() && descriptor.getOptimisticLockingPolicy().isStoredInCache()) { cacheKey.setWriteLockValue(unitOfWork.getIdentityMapAccessor().getWriteLockValue(clone));