/** * 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 database column name to the cache index. */ public void addFieldName(String field) { addField(new DatabaseField(field)); }
/** * Index the cache key by the index values. */ public void putCacheKeyByIndex(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) { if (this.cacheIndexes == null) { return; } if (indexValues == null) { return; } IdentityMap map = this.cacheIndexes.get(index); if (map == null) { synchronized (this.cacheIndexes) { map = this.cacheIndexes.get(index); if (map == null) { map = buildNewIdentityMap(index.getCacheType(), index.getCacheSize(), null, false); this.cacheIndexes.put(index, map); } } } map.put(indexValues, cacheKey, null, 0); }
existingIndex = new CacheIndex(fields); existingIndex.setIsUpdateable(false); existingIndex.setIsInsertable(false);
if ((changeSet == null) || (changeSet.isNew() && index.isInsertable()) || (!changeSet.isNew() && index.isUpdateable())) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size];
/** * 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: * Index the object by index in the cache using its row. */ public void indexObjectInCache(CacheKey cacheKey, AbstractRecord databaseRow, Object domainObject, ClassDescriptor descriptor, AbstractSession session, boolean refresh) { if (!hasCacheIndexes()) { return; } for (CacheIndex index : this.cacheIndexes.values()) { if (!refresh || index.isUpdateable()) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size]; for (int count = 0; count < size; count++) { values[count] = databaseRow.get(fields.get(count)); } CacheId indexValues = new CacheId(values); session.getIdentityMapAccessorInstance().putCacheKeyByIndex(index, indexValues, cacheKey, descriptor); } } }
@Override public String toString() { return "CacheIndex(" + getFields() + ")"; } }
existingIndex = new CacheIndex(fields); existingIndex.setIsUpdateable(false); existingIndex.setIsInsertable(false);
if ((changeSet == null) || (changeSet.isNew() && index.isInsertable()) || (!changeSet.isNew() && index.isUpdateable())) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size];
/** * INTERNAL: * Index the object by index in the cache using its row. */ public void indexObjectInCache(CacheKey cacheKey, AbstractRecord databaseRow, Object domainObject, ClassDescriptor descriptor, AbstractSession session, boolean refresh) { if (!hasCacheIndexes()) { return; } for (CacheIndex index : this.cacheIndexes.values()) { if (!refresh || index.isUpdateable()) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size]; for (int count = 0; count < size; count++) { values[count] = databaseRow.get(fields.get(count)); } CacheId indexValues = new CacheId(values); session.getIdentityMapAccessorInstance().putCacheKeyByIndex(index, indexValues, cacheKey, descriptor); } } }
public String toString() { return "CacheIndex(" + getFields() + ")"; } }
/** * INTERNAL: * Index the object by index in the cache using the object. */ public void indexObjectInCache(CacheKey cacheKey, Object object, ClassDescriptor descriptor, AbstractSession session, boolean refresh) { if (!hasCacheIndexes()) { return; } for (CacheIndex index : this.cacheIndexes.values()) { if (!refresh || index.isUpdateable()) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size]; for (int count = 0; count < size; count++) { values[count] = descriptor.getObjectBuilder().extractValueFromObjectForField(object, fields.get(count), session); } CacheId indexValues = new CacheId(values); session.getIdentityMapAccessorInstance().putCacheKeyByIndex(index, indexValues, cacheKey, descriptor); } } }
/** * 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(CacheIndex index) { getCacheIndexes().put(index.getFields(), index); }
/** * 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)); }
/** * Index the cache key by the index values. */ public void putCacheKeyByIndex(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) { if (this.cacheIndexes == null) { return; } if (indexValues == null) { return; } IdentityMap map = this.cacheIndexes.get(index); if (map == null) { synchronized (this.cacheIndexes) { map = this.cacheIndexes.get(index); if (map == null) { map = buildNewIdentityMap(index.getCacheType(), index.getCacheSize(), null, false); this.cacheIndexes.put(index, map); } } } map.put(indexValues, cacheKey, null, 0); }
/** * PUBLIC: * Add the database column name to the cache index. */ public void addFieldName(String field) { addField(new DatabaseField(field)); }
/** * INTERNAL: * Index the object by index in the cache using the object. */ public void indexObjectInCache(CacheKey cacheKey, Object object, ClassDescriptor descriptor, AbstractSession session, boolean refresh) { if (!hasCacheIndexes()) { return; } for (CacheIndex index : this.cacheIndexes.values()) { if (!refresh || index.isUpdateable()) { List<DatabaseField> fields = index.getFields(); int size = fields.size(); Object[] values = new Object[size]; for (int count = 0; count < size; count++) { values[count] = descriptor.getObjectBuilder().extractValueFromObjectForField(object, fields.get(count), session); } CacheId indexValues = new CacheId(values); session.getIdentityMapAccessorInstance().putCacheKeyByIndex(index, indexValues, cacheKey, descriptor); } } }
/** * 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(CacheIndex index) { getCacheIndexes().put(index.getFields(), index); }
/** * 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)); }