value = ((ParameterExpression)getBaseExpression()).getValue(translationRow, session);
if (value == null) {
return null;
}
ClassDescriptor descriptor = session.getDescriptor(value);
//Bug4924639 Aggregate descriptors have to be acquired from their mapping as they are cloned and initialized by each mapping
if (descriptor.isAggregateDescriptor() && ((ParameterExpression)getBaseExpression()).getLocalBase().isObjectExpression()) {
descriptor = ((ObjectExpression)((ParameterExpression)getBaseExpression()).getLocalBase()).getDescriptor();
}
if (descriptor != null) {
// For bug 2990493 must unwrap for EJBQL "Select Person(p) where p = ?1"
//if we had to unwrap it make sure we replace the argument with this value
//incase it is needed again, say in conforming.
//bug 3750793
value = descriptor.getObjectBuilder().unwrapObject(value, session);
translationRow.put(((ParameterExpression)getBaseExpression()).getField(), value);
// The local parameter is either a field or attribute of the object.
DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(getField());
if (mapping != null) {
value = mapping.valueFromObject(value, getField(), session);
} else {
mapping = descriptor.getObjectBuilder().getMappingForAttributeName(getField().getName());
if (mapping != null) {
value = mapping.getRealAttributeValueFromObject(value, session);
} else {
DatabaseField queryKeyField = descriptor.getObjectBuilder().getFieldForQueryKeyName(getField().getName());
if (queryKeyField != null) {
mapping = descriptor.getObjectBuilder().getMappingForField(getField());
if (mapping != null) {
value = mapping.valueFromObject(value, getField(), session);
}
}
}