/** * PUBLIC: * Controls how the Entity instances and data will be cached. See the CacheIsolationType for details on the options. * To disable all second level caching simply set CacheIsolationType.ISOLATED. Note that setting the isolation * will automatically set the corresponding cacheSynchronizationType. * ISOLATED = DO_NOT_SEND_CHANGES, PROTECTED and SHARED = SEND_OBJECT_CHANGES */ public void setCacheIsolation(CacheIsolationType isolationType) { getCachePolicy().setCacheIsolation(isolationType); }
/** * PUBLIC: * Controls how the Entity instances and data will be cached. See the CacheIsolationType for details on the options. * To disable all second level caching simply set CacheIsolationType.ISOLATED. Note that setting the isolation * will automatically set the corresponding cacheSynchronizationType. * ISOLATED = DO_NOT_SEND_CHANGES, PROTECTED and SHARED = SEND_OBJECT_CHANGES */ public void setCacheIsolation(CacheIsolationType isolationType) { getCachePolicy().setCacheIsolation(isolationType); }
/** * PUBLIC: * Used to set if the class that this descriptor represents should be isolated from the shared cache. * Isolated objects will only be cached locally in the ClientSession, never in the ServerSession cache. * This is the best method for disabling caching. * Note: Calling this method with true will also set the cacheSynchronizationType to DO_NOT_SEND_CHANGES * since isolated objects cannot be sent by cache synchronization. * * @deprecated as of EclipseLink 2.2 * @see #setCacheIsolation(CacheIsolationType) */ @Deprecated public void setIsIsolated(boolean isIsolated) { getCachePolicy().setCacheIsolation( isIsolated ? CacheIsolationType.ISOLATED : CacheIsolationType.SHARED); }
/** * PUBLIC: * Used to set if the class that this descriptor represents should be isolated from the shared cache. * Isolated objects will only be cached locally in the ClientSession, never in the ServerSession cache. * This is the best method for disabling caching. * Note: Calling this method with true will also set the cacheSynchronizationType to DO_NOT_SEND_CHANGES * since isolated objects cannot be sent by cache synchronization. * * @deprecated as of EclipseLink 2.2 * @see #setCacheIsolation(CacheIsolationType) */ @Deprecated public void setIsIsolated(boolean isIsolated) { getCachePolicy().setCacheIsolation( isIsolated ? CacheIsolationType.ISOLATED : CacheIsolationType.SHARED); }
/** * INTERNAL: * Initialize the mapping. */ @Override public void postInitialize(AbstractSession session) throws DescriptorException { super.postInitialize(session); if (getReferenceDescriptor() != null) { getReferenceDescriptor().getCachePolicy().setCacheIsolation(this.descriptor.getCachePolicy().getCacheIsolation()); // Changed as part of fix for bug#4410581 aggregate mapping can not be set to use change tracking if owning descriptor does not use it. // Basically the policies should be the same, but we also allow deferred with attribute for CMP2 (courser grained). if (getDescriptor().getObjectChangePolicy().getClass().equals(DeferredChangeDetectionPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new DeferredChangeDetectionPolicy()); } else if (getDescriptor().getObjectChangePolicy().getClass().equals(ObjectChangeTrackingPolicy.class) && getReferenceDescriptor().getObjectChangePolicy().getClass().equals(AttributeChangeTrackingPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new ObjectChangeTrackingPolicy()); } } }
/** * INTERNAL: * Initialize the mapping. */ @Override public void postInitialize(AbstractSession session) throws DescriptorException { super.postInitialize(session); if (getReferenceDescriptor() != null) { getReferenceDescriptor().getCachePolicy().setCacheIsolation(this.descriptor.getCachePolicy().getCacheIsolation()); // Changed as part of fix for bug#4410581 aggregate mapping can not be set to use change tracking if owning descriptor does not use it. // Basically the policies should be the same, but we also allow deferred with attribute for CMP2 (courser grained). if (getDescriptor().getObjectChangePolicy().getClass().equals(DeferredChangeDetectionPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new DeferredChangeDetectionPolicy()); } else if (getDescriptor().getObjectChangePolicy().getClass().equals(ObjectChangeTrackingPolicy.class) && getReferenceDescriptor().getObjectChangePolicy().getClass().equals(AttributeChangeTrackingPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new ObjectChangeTrackingPolicy()); } } }
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
if (!mapping.isCacheable()) { if (isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED); if (referencedDescriptor!= null) { if (isSharedIsolation() && !referencedDescriptor.getCachePolicy().isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED); if (referencedDescriptor != null) { if (isSharedIsolation() && !referencedDescriptor.getCachePolicy().isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED);
if (!mapping.isCacheable()) { if (isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED); if (referencedDescriptor!= null) { if (isSharedIsolation() && !referencedDescriptor.getCachePolicy().isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED); if (referencedDescriptor != null) { if (isSharedIsolation() && !referencedDescriptor.getCachePolicy().isSharedIsolation()) { setCacheIsolation(CacheIsolationType.PROTECTED);
getReferenceDescriptor().getCachePolicy().setCacheIsolation(this.descriptor.getCachePolicy().getCacheIsolation());
/** * INTERNAL: * For an aggregate mapping the reference descriptor is cloned. The cloned descriptor is then * assigned primary keys and table names before initialize. Once the cloned descriptor is initialized * it is assigned as reference descriptor in the aggregate mapping. This is a very specific * behavior for aggregate mappings. The original descriptor is used only for creating clones and * after that the aggregate mapping never uses it. * Some initialization is done in postInitialize to ensure the target descriptor's references are initialized. */ @Override public void postInitialize(AbstractSession session) throws DescriptorException { super.postInitialize(session); if (getReferenceDescriptor() != null) { getReferenceDescriptor().getCachePolicy().setCacheIsolation(this.descriptor.getCachePolicy().getCacheIsolation()); // Changed as part of fix for bug#4410581 aggregate mapping can not be set to use change tracking if owning descriptor does not use it. // Basically the policies should be the same, but we also allow deferred with attribute for CMP2 (courser grained). if (getDescriptor().getObjectChangePolicy().getClass().equals(DeferredChangeDetectionPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new DeferredChangeDetectionPolicy()); } else if (getDescriptor().getObjectChangePolicy().getClass().equals(ObjectChangeTrackingPolicy.class) && getReferenceDescriptor().getObjectChangePolicy().getClass().equals(AttributeChangeTrackingPolicy.class)) { getReferenceDescriptor().setObjectChangePolicy(new ObjectChangeTrackingPolicy()); } //need to set the primary key classification as the mappings for the pk fields might not be available if (getReferenceDescriptor().isAggregateDescriptor()){ getReferenceDescriptor().getObjectBuilder().setPrimaryKeyClassifications(this.getDescriptor().getObjectBuilder().getPrimaryKeyClassifications()); getReferenceDescriptor().setHasSimplePrimaryKey(this.getDescriptor().hasSimplePrimaryKey()); } getReferenceDescriptor().postInitialize(session); } }
classDescriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.ISOLATED); classDescriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.valueOf(m_isolation));
/** * INTERNAL: * Allow the inheritance properties of the descriptor to be initialized. * The descriptor's parent must first be initialized. */ public void initializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, AbstractSession session) throws DescriptorException { // If the parent is isolated, then the child must also be isolated. if (!parentPolicy.isSharedIsolation()) { // Do not override cache isolation when explicitly enabled by @Cacheable(true) annotation in current class. boolean copyParrent = cacheable == null || cacheable == false; if (!isIsolated() && (getCacheIsolation() != parentPolicy.getCacheIsolation()) && copyParrent) { session.log(SessionLog.WARNING, SessionLog.METADATA, "overriding_cache_isolation", new Object[]{descriptorDescriptor.getAlias(), parentPolicy.getCacheIsolation(), descriptor.getAlias(), getCacheIsolation()}); setCacheIsolation(parentPolicy.getCacheIsolation()); } } // Child must maintain the same indexes as the parent. for (CacheIndex index : parentPolicy.getCacheIndexes().values()) { addCacheIndex(index); } if ((getDatabaseChangeNotificationType() == null) && (parentPolicy.getDatabaseChangeNotificationType() != null)) { setDatabaseChangeNotificationType(parentPolicy.getDatabaseChangeNotificationType()); } if ((getCacheSynchronizationType() == UNDEFINED_OBJECT_CHANGE_BEHAVIOR) && (parentPolicy.getCacheSynchronizationType() != UNDEFINED_OBJECT_CHANGE_BEHAVIOR)) { setCacheSynchronizationType(parentPolicy.getCacheSynchronizationType()); } }
/** * INTERNAL: * Allow the inheritance properties of the descriptor to be initialized. * The descriptor's parent must first be initialized. */ public void initializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, AbstractSession session) throws DescriptorException { // If the parent is isolated, then the child must also be isolated. if (!parentPolicy.isSharedIsolation()) { // Do not override cache isolation when explicitly enabled by @Cacheable(true) annotation in current class. boolean copyParrent = cacheable == null || cacheable == false; if (!isIsolated() && (getCacheIsolation() != parentPolicy.getCacheIsolation()) && copyParrent) { session.log(SessionLog.WARNING, SessionLog.METADATA, "overriding_cache_isolation", new Object[]{descriptorDescriptor.getAlias(), parentPolicy.getCacheIsolation(), descriptor.getAlias(), getCacheIsolation()}); setCacheIsolation(parentPolicy.getCacheIsolation()); } } // Child must maintain the same indexes as the parent. for (CacheIndex index : parentPolicy.getCacheIndexes().values()) { addCacheIndex(index); } if ((getDatabaseChangeNotificationType() == null) && (parentPolicy.getDatabaseChangeNotificationType() != null)) { setDatabaseChangeNotificationType(parentPolicy.getDatabaseChangeNotificationType()); } if ((getCacheSynchronizationType() == UNDEFINED_OBJECT_CHANGE_BEHAVIOR) && (parentPolicy.getCacheSynchronizationType() != UNDEFINED_OBJECT_CHANGE_BEHAVIOR)) { setCacheSynchronizationType(parentPolicy.getCacheSynchronizationType()); } }