*/
protected Object extractValueFromExpression(Expression expression, DatabaseQuery query) {
Object value = null;
expression.getBuilder().setSession(query.getSession());
if (expression.isQueryKeyExpression()) {
QueryKeyExpression queryKeyExpression = (QueryKeyExpression)expression;
value = queryKeyExpression.getField();
if ((queryKeyExpression.getMapping() != null) && queryKeyExpression.getMapping().getDescriptor().isDescriptorTypeAggregate()) {
String name = queryKeyExpression.getField().getName();
while (queryKeyExpression.getBaseExpression().isQueryKeyExpression()
&& (((QueryKeyExpression)queryKeyExpression.getBaseExpression()).getMapping().isAbstractCompositeObjectMapping()
|| ((QueryKeyExpression)queryKeyExpression.getBaseExpression()).getMapping().isAbstractCompositeCollectionMapping()
|| ((QueryKeyExpression)queryKeyExpression.getBaseExpression()).getMapping().isAbstractCompositeDirectCollectionMapping())) {
queryKeyExpression = (QueryKeyExpression)queryKeyExpression.getBaseExpression();
if (queryKeyExpression.getMapping().isAbstractCompositeObjectMapping()) {
name = ((AbstractCompositeObjectMapping)queryKeyExpression.getMapping()).getField().getName() + "." + name;
} else if (queryKeyExpression.getMapping().isAbstractCompositeCollectionMapping()) {
name = ((AbstractCompositeCollectionMapping)queryKeyExpression.getMapping()).getField().getName() + "." + name;
} else if (queryKeyExpression.getMapping().isAbstractCompositeDirectCollectionMapping()) {
name = ((AbstractCompositeDirectCollectionMapping)queryKeyExpression.getMapping()).getField().getName() + "." + name;
}
}
DatabaseField field = new DatabaseField();
field.setName(name);
value = field;