/** * Return the base mapping for the given DatabaseField. */ public DatabaseMapping getBaseMappingForField(DatabaseField databaseField) { DatabaseMapping mapping = getMappingForField(databaseField); // Drill down through the mappings until we get the direct mapping to the databaseField. while (mapping.isAggregateObjectMapping()) { mapping = ((AggregateObjectMapping)mapping).getReferenceDescriptor().getObjectBuilder().getMappingForField(databaseField); } return mapping; }
/** * Return the base value that is mapped to for given field. */ public Object getParentObjectForField(DatabaseField databaseField, Object domainObject) { Object valueIntoObject = domainObject; DatabaseMapping mapping = getMappingForField(databaseField); // Drill down through the aggregate mappings to get to the direct to field mapping. while (mapping.isAggregateObjectMapping()) { valueIntoObject = mapping.getAttributeValueFromObject(valueIntoObject); mapping = ((AggregateMapping)mapping).getReferenceDescriptor().getObjectBuilder().getMappingForField(databaseField); } return valueIntoObject; }
/** * INTERNAL: * Assign values from objectRow to the object through the mapping. */ protected void assignReturnValueToMapping(Object object, ReadObjectQuery query, AbstractRecord row, DatabaseField field, DatabaseMapping mapping, Collection handledMappings) { if (handledMappings.contains(mapping)) { return; } Object attributeValue; if (mapping.isAggregateObjectMapping()) { attributeValue = ((AggregateObjectMapping)mapping).readFromReturnRowIntoObject(row, object, query, handledMappings); } else if (mapping.isDirectToFieldMapping()) { attributeValue = mapping.readFromRowIntoObject(row, null, object, query); } else { query.getSession().log(SessionLog.FINEST, SessionLog.QUERY, "field_for_unsupported_mapping_returned", field, getDescriptor()); } }
/** * Return the base value that is mapped to for given field. */ public Object getBaseValueForField(DatabaseField databaseField, Object domainObject) { Object valueIntoObject = domainObject; DatabaseMapping mapping = getMappingForField(databaseField); // Drill down through the aggregate mappings to get to the direct to field mapping. while (mapping.isAggregateObjectMapping()) { valueIntoObject = mapping.getAttributeValueFromObject(valueIntoObject); mapping = ((AggregateMapping)mapping).getReferenceDescriptor().getObjectBuilder().getMappingForField(databaseField); } return mapping.getAttributeValueFromObject(valueIntoObject); }
getMappingsByField().put(secondaryField, mapping); if (mapping.isAggregateObjectMapping()) {
mapping = this.getDescriptor().getObjectBuilder().getMappingForField(pkElementArray[index].getDatabaseField()); while (mapping.isAggregateObjectMapping()) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName()); if (mapping == null) {// must be aggregate
public void iterate(Expression each) { if(getResult() == null) { return; } if(each instanceof DataExpression) { DataExpression dataExpression = (DataExpression)each; Expression baseExpression = dataExpression.getBaseExpression(); if(baseExpression != null && !(baseExpression instanceof ExpressionBuilder)) { boolean stop = true; if(baseExpression instanceof DataExpression) { DataExpression baseDataExpression = (DataExpression)baseExpression; if(baseDataExpression.getMapping() != null && baseDataExpression.getMapping().isAggregateObjectMapping()) { stop = false; } } if(stop) { setResult(null); return; } } DatabaseField field = dataExpression.getField(); if(field != null) { if(!field.getTable().equals((DatabaseTable)getResult())) { setResult(null); return; } } } } public boolean shouldIterateOverSubSelects() {
validateMappingType(mapping); mapping.initialize(session); if (mapping.isAggregateObjectMapping() || ((mapping.isForeignReferenceMapping() && (!mapping.isDirectCollectionMapping())) && (!((ForeignReferenceMapping)mapping).usesIndirection()))) { getLockableMappings().add(mapping); iterator.hasNext();) { DatabaseMapping mapping = (DatabaseMapping)iterator.next(); if (mapping.isAggregateObjectMapping() || ((mapping.isForeignReferenceMapping() && (!mapping.isDirectCollectionMapping())) && (!((ForeignReferenceMapping)mapping).usesIndirection()))) {
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { if (isAttribute() || ((getMapping() != null) && (getMapping().isAggregateObjectMapping() || getMapping().isTransformationMapping()))) { return ((DataExpression)getBaseExpression()).aliasForTable(table); } //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table if ((getMapping() != null) && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) { DatabaseTable alias = getBaseExpression().aliasForTable((DatabaseTable)getMapping().getDescriptor().getTables().firstElement()); alias.setName(alias.getName() + "." + getMapping().getField().getName()); return alias; } return super.aliasForTable(table); }
/** * INTERNAL: * Create an instance of the composite primary key class for the key object. */ public Object createPrimaryKeyInstance(Object key, AbstractSession session) { Object keyInstance = getPKClassInstance(); ObjectBuilder builder = getDescriptor().getObjectBuilder(); KeyElementAccessor[] pkElementArray = this.getKeyClassFields(getPKClass()); for (int index = 0; index < pkElementArray.length; index++) { KeyElementAccessor accessor = pkElementArray[index]; DatabaseMapping mapping = builder.getMappingForAttributeName(accessor.getAttributeName()); // With session validation, the mapping shouldn't be null at this // point, don't bother checking. while (mapping.isAggregateObjectMapping()) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName()); if (mapping == null) { // must be aggregate mapping = builder.getMappingForField(accessor.getDatabaseField()); } } Object fieldValue = mapping.getRealAttributeValueFromObject(key, (oracle.toplink.essentials.internal.sessions.AbstractSession) session); accessor.setValue(keyInstance, fieldValue); } return keyInstance; }
mapping = this.getDescriptor().getObjectBuilder().getMappingForField(field); while (mapping.isAggregateObjectMapping()) { Object aggregate = mapping.getRealAttributeValueFromObject(toWriteInto, session); if (aggregate == null) {
return; if (mapping.isAggregateObjectMapping()) { Object aggregate = mapping.getAttributeValueFromObject(object); AggregateChangeRecord record = (AggregateChangeRecord)objectChangeSet.getChangesForAttributeNamed(mapping.getAttributeName());
while (readMappingFromQueryKey && mapping.isAggregateObjectMapping() && !((AggregateObjectMapping)mapping).getReferenceClass().equals(queryKey.getDescriptor().getJavaClass())) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(((DirectQueryKey)queryKey).getField()); aggregateValue = mapping.getRealAttributeValueFromObject(aggregateValue, session);
throw QueryException.invalidExpressionForQueryItem(expression, this); } else if (mapping.isAggregateObjectMapping()) { descriptor = ((AggregateObjectMapping)mapping).getReferenceDescriptor(); } else if (mapping.isForeignReferenceMapping()) {
while (pk.isAggregateObjectMapping()) { newDescriptor = ((AggregateObjectMapping)pk).getReferenceDescriptor(); pk = getMappingOfFirstPrimaryKey(newDescriptor);
if (mapping != null && (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping())){ mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true; if (mapping != null && (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping())){ mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true;