/** * ADVANCED: * Return what cache key type to use to store the object in the cache. */ public CacheKeyType getCacheKeyType() { return getCachePolicy().getCacheKeyType(); }
/** * ADVANCED: * Return what cache key type to use to store the object in the cache. */ public CacheKeyType getCacheKeyType() { return getCachePolicy().getCacheKeyType(); }
/** * INTERNAL: * Create an instance of the composite primary key class for the key object. */ public Object createPrimaryKeyInstanceFromId(Object key, AbstractSession session) { if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.CACHE_ID) { return createPrimaryKeyInstanceFromPrimaryKeyValues(session, new int[]{0}, ((CacheId)key).getPrimaryKey()); } else { return createPrimaryKeyInstanceFromPrimaryKeyValues(session, new int[]{0}, key); } }
/** * INTERNAL: * Create an instance of the composite primary key class for the key object. */ public Object createPrimaryKeyInstanceFromId(Object key, AbstractSession session) { if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.CACHE_ID) { return createPrimaryKeyInstanceFromPrimaryKeyValues(session, new int[]{0}, ((CacheId)key).getPrimaryKey()); } else { return createPrimaryKeyInstanceFromPrimaryKeyValues(session, new int[]{0}, key); } }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }
if (this.elementDescriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.CACHE_ID){ foreignKeyValues.add(Arrays.asList(((CacheId)pk).getPrimaryKey())); }else{
List foreignKeyValues = new ArrayList(keyInfo.length - fromCache.size()); CacheKeyType cacheKeyType = referenceDescriptor.getCachePolicy().getCacheKeyType(); for (int index = 0; index < keyInfo.length; ++index){ Object pk = keyInfo[index];
List foreignKeyValues = new ArrayList(keyInfo.length - fromCache.size()); CacheKeyType cacheKeyType = referenceDescriptor.getCachePolicy().getCacheKeyType(); for (int index = 0; index < keyInfo.length; ++index){ Object pk = keyInfo[index];
List foreignKeyValues = new ArrayList(pks.length - fromCache.size()); CacheKeyType cacheKeyType = this.elementDescriptor.getCachePolicy().getCacheKeyType(); for (int index = 0; index < mapSize; ++index){ Object pk = values[index];
Object pk = pks[index]; if (!fromCache.containsKey(pk)){ if (this.elementDescriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.CACHE_ID){ foreignKeyValues.add(Arrays.asList(((CacheId)pk).getPrimaryKey())); }else{
/** * Build the primary key expression from the specified primary key values. */ public Expression buildPrimaryKeyExpressionFromKeys(Object primaryKey, AbstractSession session) { Expression builder = new ExpressionBuilder(); List<DatabaseField> primaryKeyFields = this.descriptor.getPrimaryKeyFields(); if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return builder.getField(primaryKeyFields.get(0)).equal(primaryKey); } Expression expression = null; int size = primaryKeyFields.size(); Object[] primaryKeyValues = null; if (primaryKey == null) { primaryKeyValues = new Object[size]; } else { primaryKeyValues = ((CacheId)primaryKey).getPrimaryKey(); } for (int index = 0; index < size; index++) { Object value = primaryKeyValues[index]; DatabaseField field = primaryKeyFields.get(index); if (value != null) { Expression subExpression = builder.getField(field).equal(value); expression = subExpression.and(expression); } } return expression; }
/** * Build the primary key expression from the specified primary key values. */ public Expression buildPrimaryKeyExpressionFromKeys(Object primaryKey, AbstractSession session) { Expression builder = new ExpressionBuilder(); List<DatabaseField> primaryKeyFields = this.descriptor.getPrimaryKeyFields(); if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return builder.getField(primaryKeyFields.get(0)).equal(primaryKey); } Expression expression = null; int size = primaryKeyFields.size(); Object[] primaryKeyValues = null; if (primaryKey == null) { primaryKeyValues = new Object[size]; } else { primaryKeyValues = ((CacheId)primaryKey).getPrimaryKey(); } for (int index = 0; index < size; index++) { Object value = primaryKeyValues[index]; DatabaseField field = primaryKeyFields.get(index); if (value != null) { Expression subExpression = builder.getField(field).equal(value); expression = subExpression.and(expression); } } return expression; }
int size = primaryKeyFields.size(); Object[] primaryKeyValues = null; CacheKeyType cacheKeyType = this.descriptor.getCachePolicy().getCacheKeyType(); if (cacheKeyType != CacheKeyType.ID_VALUE) { primaryKeyValues = new Object[size];
int size = primaryKeyFields.size(); Object[] primaryKeyValues = null; CacheKeyType cacheKeyType = this.descriptor.getCachePolicy().getCacheKeyType(); if (cacheKeyType != CacheKeyType.ID_VALUE) { primaryKeyValues = new Object[size];
/** * Build the row from the primary key values. */ public AbstractRecord writeIntoRowFromPrimaryKeyValues(AbstractRecord row, Object primaryKey, AbstractSession session, boolean convert) { List<DatabaseField> primaryKeyFields = this.descriptor.getPrimaryKeyFields(); if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { DatabaseField field = primaryKeyFields.get(0); Object value = primaryKey; value = session.getPlatform(this.descriptor.getJavaClass()).getConversionManager().convertObject(value, field.getType()); row.put(field, value); return row; } int size = primaryKeyFields.size(); Object[] primaryKeyValues = ((CacheId)primaryKey).getPrimaryKey(); for (int index = 0; index < size; index++) { DatabaseField field = primaryKeyFields.get(index); Object value = primaryKeyValues[index]; value = session.getPlatform(this.descriptor.getJavaClass()).getConversionManager().convertObject(value, field.getType()); row.put(field, value); } return row; }
/** * Build the row from the primary key values. */ public AbstractRecord writeIntoRowFromPrimaryKeyValues(AbstractRecord row, Object primaryKey, AbstractSession session, boolean convert) { List<DatabaseField> primaryKeyFields = this.descriptor.getPrimaryKeyFields(); if (this.descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { DatabaseField field = primaryKeyFields.get(0); Object value = primaryKey; value = session.getPlatform(this.descriptor.getJavaClass()).getConversionManager().convertObject(value, field.getType()); row.put(field, value); return row; } int size = primaryKeyFields.size(); Object[] primaryKeyValues = ((CacheId)primaryKey).getPrimaryKey(); for (int index = 0; index < size; index++) { DatabaseField field = primaryKeyFields.get(index); Object value = primaryKeyValues[index]; value = session.getPlatform(this.descriptor.getJavaClass()).getConversionManager().convertObject(value, field.getType()); row.put(field, value); } return row; }
if (descriptor.getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { if (((List)id).isEmpty()) { primaryKey = null;