/** * PUBLIC: * Add the cache index to the descriptor's cache settings. * This allows for cache hits to be obtained on non-primary key fields. * The primary key is always indexed in the cache. * Cache indexes are defined by their database column names. */ public void addCacheIndex(DatabaseField fields[]) { addCacheIndex(new CacheIndex(fields)); }
/** * PUBLIC: * Add the cache index to the descriptor's cache settings. * This allows for cache hits to be obtained on non-primary key fields. * The primary key is always indexed in the cache. * Cache indexes are defined by their database column names. */ public void addCacheIndex(String... fields) { addCacheIndex(new CacheIndex(fields)); }
/** * PUBLIC: * Add the cache index to the descriptor's cache settings. * This allows for cache hits to be obtained on non-primary key fields. * The primary key is always indexed in the cache. * Cache indexes are defined by their database column names. */ public void addCacheIndex(String... fields) { addCacheIndex(new CacheIndex(fields)); }
/** * PUBLIC: * Add the cache index to the descriptor's cache settings. * This allows for cache hits to be obtained on non-primary key fields. * The primary key is always indexed in the cache. * Cache indexes are defined by their database column names. */ public void addCacheIndex(DatabaseField fields[]) { addCacheIndex(new CacheIndex(fields)); }
/** * INTERNAL: * Process the index metadata */ public void process(MetadataDescriptor descriptor, String defaultColumnName) { if (m_columnNames.isEmpty() && (defaultColumnName != null)) { CachePolicy cachePolicy = descriptor.getClassDescriptor().getCachePolicy(); DatabaseField field = new DatabaseField(defaultColumnName); if (m_project.useDelimitedIdentifier()) { field.setUseDelimiters(true); } else if (m_project.getShouldForceFieldNamesToUpperCase() && !field.shouldUseDelimiters()) { field.useUpperCaseForComparisons(true); } cachePolicy.addCacheIndex(new DatabaseField[] {field}); } else { CacheIndex index = new CacheIndex(); if (this.updateable != null) { index.setIsUpdateable(this.updateable); } for (String column : m_columnNames) { index.addFieldName(column); } descriptor.getClassDescriptor().getCachePolicy().addCacheIndex(index); } }
/** * 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()); } }
existingIndex.setIsInsertable(false); descriptor.getCachePolicy().addCacheIndex(existingIndex);
existingIndex.setIsInsertable(false); descriptor.getCachePolicy().addCacheIndex(existingIndex);