/** * PUBLIC: * Controls how the Entity instances will be cached. See the CacheIsolationType for details on the options. * @return the isolationType */ public CacheIsolationType getCacheIsolation() { return getCachePolicy().getCacheIsolation(); }
/** * PUBLIC: * Controls how the Entity instances will be cached. See the CacheIsolationType for details on the options. * @return the isolationType */ public CacheIsolationType getCacheIsolation() { return getCachePolicy().getCacheIsolation(); }
/** * 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()); } }
/** * 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); } } } } }
/** * 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); } }
getReferenceDescriptor().getCachePolicy().setCacheIsolation(this.descriptor.getCachePolicy().getCacheIsolation());