/** * INTERNAL: * Lookup the expression in the cache if it contains any indexes. */ public boolean isIndexableExpression(Expression expression, ClassDescriptor descriptor, AbstractSession session) { if (!hasCacheIndexes()) { return false; } for (CacheIndex index : this.cacheIndexes.values()) { List<DatabaseField> searchFields = index.getFields(); int size = searchFields.size(); Set<DatabaseField> foundFields = new HashSet(size); boolean isValid = expression.extractFields(true, false, descriptor, searchFields, foundFields); if (isValid && (foundFields.size() == size)) { return true; } } return false; }
/** * INTERNAL: * Lookup the expression in the cache if it contains any indexes. */ public boolean isIndexableExpression(Expression expression, ClassDescriptor descriptor, AbstractSession session) { if (!hasCacheIndexes()) { return false; } for (CacheIndex index : this.cacheIndexes.values()) { List<DatabaseField> searchFields = index.getFields(); int size = searchFields.size(); Set<DatabaseField> foundFields = new HashSet(size); boolean isValid = expression.extractFields(true, false, descriptor, searchFields, foundFields); if (isValid && (foundFields.size() == size)) { return true; } } return false; }
/** * 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); } } }
/** * 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); } } }
/** * 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); } } }
/** * 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); } } }
if (!hasCacheIndexes()) { return null;
if (!hasCacheIndexes()) { return null;
/** * INTERNAL: * Post initializations after mappings are initialized. */ public void postInitialize(AbstractSession session) throws DescriptorException { // PERF: Cache if needs to unwrap to optimize unwrapping. this.hasWrapperPolicy = this.descriptor.hasWrapperPolicy() || session.getProject().hasProxyIndirection(); // PERF: Used by ObjectLevelReadQuery ResultSetAccessOptimization. this.shouldKeepRow = false; for (DatabaseField field : this.descriptor.getFields()) { if (field.keepInRow()) { this.shouldKeepRow = true; break; } } // PERF: is there an cache index field that's would not be selected by SOP query. Ignored unless descriptor uses SOP and CachePolicy has cache indexes. if (this.descriptor.hasSerializedObjectPolicy() && this.descriptor.getCachePolicy().hasCacheIndexes()) { for (List<DatabaseField> indexFields : this.descriptor.getCachePolicy().getCacheIndexes().keySet()) { if (!this.descriptor.getSerializedObjectPolicy().getSelectionFields().containsAll(indexFields)) { this.hasCacheIndexesInSopObject = true; break; } } } }
/** * INTERNAL: * Post initializations after mappings are initialized. */ public void postInitialize(AbstractSession session) throws DescriptorException { // PERF: Cache if needs to unwrap to optimize unwrapping. this.hasWrapperPolicy = this.descriptor.hasWrapperPolicy() || session.getProject().hasProxyIndirection(); // PERF: Used by ObjectLevelReadQuery ResultSetAccessOptimization. this.shouldKeepRow = false; for (DatabaseField field : this.descriptor.getFields()) { if (field.keepInRow()) { this.shouldKeepRow = true; break; } } // PERF: is there an cache index field that's would not be selected by SOP query. Ignored unless descriptor uses SOP and CachePolicy has cache indexes. if (this.descriptor.hasSerializedObjectPolicy() && this.descriptor.getCachePolicy().hasCacheIndexes()) { for (List<DatabaseField> indexFields : this.descriptor.getCachePolicy().getCacheIndexes().keySet()) { if (!this.descriptor.getSerializedObjectPolicy().getSelectionFields().containsAll(indexFields)) { this.hasCacheIndexesInSopObject = true; break; } } } }
if (!hasCacheIndexes()) { return;
if (hasCacheIndexes()) { for (CacheIndex index : getCacheIndexes().values()) { for (int count = 0; count < index.getFields().size(); count++) {
if (hasCacheIndexes()) { for (CacheIndex index : getCacheIndexes().values()) { for (int count = 0; count < index.getFields().size(); count++) {