public void postBuild(DescriptorEvent event) { RelationExpression expression = (RelationExpression)event.getObject(); if ((expression.getFirstChild() != null) && (expression.getSecondChild() != null)) { if (expression.getSecondChild().isValueExpression()) { expression.getSecondChild().setLocalBase(expression.getFirstChild()); } if (expression.getFirstChild().isValueExpression()) { expression.getFirstChild().setLocalBase(expression.getSecondChild()); } } } });
/** * INTERNAL: * Modify this individual expression node to use outer joins wherever there are * equality operations between two field nodes. */ protected void convertNodeToUseOuterJoin() { if ((this.operator.getSelector() == ExpressionOperator.Equal) && allChildrenAreFields()) { setOperator(getOperator(ExpressionOperator.EqualOuterJoin)); } }
/** * Conform in-memory the collection of left values with the right value for this expression. * This is used for anyOf support when the left side is a collection of values. */ protected boolean doesAnyOfLeftValuesConform(Vector leftValues, Object rightValue, AbstractSession session) { // Check each left value with the right value. for (int index = 0; index < leftValues.size(); index++) { Object leftValue = leftValues.get(index); if (doValuesConform(leftValue, rightValue, session)) { // Return true if any value matches. return true; } } // Return false only if none of the values match. return false; }
/** * Conform in-memory the two values. */ protected boolean doValuesConform(Object leftValue, Object rightValue, AbstractSession session) { // Check for object comparison. if (isObjectComparison(session)) { return doesObjectConform(leftValue, rightValue, session); } else { return this.operator.doesRelationConform(leftValue, rightValue); } }
Expression optimizedExpression = checkForeignKeyJoinOptimization(this.firstChild, this.secondChild, normalizer); if (optimizedExpression == null) { optimizedExpression = checkForeignKeyJoinOptimization(this.secondChild, this.firstChild, normalizer); if (!isObjectComparison(normalizer.getSession())) { return super.normalize(normalizer); } else { validateNode(); newLeft = getBuilder().value(sourceFields); } else { newLeft = left.getField(sourceField); setFirstChild(newLeft); Expression right = this.secondChild; if (right.isConstantExpression()) { object = getBuilder().value(values); } else { object = ((Expression)object).getField(targetField); object = getBuilder().value(values); } else { object = descriptor.getObjectBuilder().extractValueFromObjectForField(object, targetField, normalizer.getSession()); foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, targetObject, getSession()); } else if (second.isObjectExpression() || second.isParameterExpression()) { foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, second, getSession());
if (expression.isRelationExpression()) { RelationExpression relation = (RelationExpression)expression; Object left = extractValueFromExpression(relation.getFirstChild(), query); Object right = extractValueFromExpression(relation.getSecondChild(), query); if (relation.getOperator().getSelector() == ExpressionOperator.Equal) { row.put(left, right); } else { DatabaseRecord nested = new DatabaseRecord(); if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThan) { nested.put("$gt", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.LessThan) { nested.put("$lt", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.LessThanEqual) { nested.put("$lte", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThanEqual) { nested.put("$gte", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.NotEqual) { nested.put("$ne", right); } else if (relation.getOperator().getSelector() == ExpressionOperator.In) { nested.put("$in", right); row.put(left, nested); } else if (relation.getOperator().getSelector() == ExpressionOperator.NotIn) { nested.put("$nin", right); row.put(left, nested); if (expr.isRelationExpression()) { RelationExpression relation = (RelationExpression)expr; Object left = extractValueFromExpression(relation.getFirstChild(), query); Object right = extractValueFromExpression(relation.getSecondChild(), query);
if (isObjectComparison(session)) { return doesAnyOfLeftValuesConform((Vector)leftValue, rightValue, session); } else { return this.operator.doesRelationConform(leftValue, rightValue); if (doesAnyOfLeftValuesConform((Vector)leftValue, tempRight, session)) { return true; if (doValuesConform(leftValue, tempRight, session)) { return true; return doesAnyOfLeftValuesConform((Vector)leftValue, rightValue, session); return doValuesConform(leftValue, rightValue, session);
if (!isObjectComparison()) { return super.normalize(normalizer); } else { validateNode(); foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, targetObject, getSession()); } else if (this.secondChild.isObjectExpression() || this.secondChild.isParameterExpression()) { foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, this.secondChild, getSession()); } else { throw QueryException.invalidUseOfToManyQueryKeyInExpression(this); first.getDescriptor().getObjectBuilder().buildPrimaryKeyExpressionFromObject(((ConstantExpression)this.secondChild).getValue(), getSession());
/** * Add to list of values to be tested against. * @param value value * @return in predicate */ public In<T> value(T value){ ((Collection)((CollectionExpression)((RelationExpression)this.currentNode).getSecondChild()).getValue()).add(value); return this; }
/** * INTERNAL: * Print SQL without adding parentheses (for DB2 outer joins). */ public void printSQLNoParens(ExpressionSQLPrinter printer) { ExpressionOperator realOperator = getPlatformOperator(printer.getPlatform()); realOperator.printDuo(this.firstChild, this.secondChild, printer); }
return new FunctionExpression(); } else if (this.nodeClass == ClassConstants.RelationExpression_Class) { return new RelationExpression(); } else if (this.nodeClass == ClassConstants.LogicalExpression_Class) { return new LogicalExpression();
mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true; mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true;
Expression optimizedExpression = checkForeignKeyJoinOptimization(this.firstChild, this.secondChild, normalizer); if (optimizedExpression == null) { optimizedExpression = checkForeignKeyJoinOptimization(this.secondChild, this.firstChild, normalizer); if (!isObjectComparison(normalizer.getSession())) { return super.normalize(normalizer); } else { validateNode(); newLeft = getBuilder().value(sourceFields); } else { newLeft = left.getField(sourceField); setFirstChild(newLeft); Expression right = this.secondChild; if (right.isConstantExpression()) { object = getBuilder().value(values); } else { object = ((Expression)object).getField(targetField); object = getBuilder().value(values); } else { object = descriptor.getObjectBuilder().extractValueFromObjectForField(object, targetField, normalizer.getSession()); foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, targetObject, getSession()); } else if (second.isObjectExpression() || second.isParameterExpression()) { foreignKeyJoin = first.getMapping().buildObjectJoinExpression(first, second, getSession());
if (isObjectComparison(session)) { return doesAnyOfLeftValuesConform((Vector)leftValue, rightValue, session); } else { return this.operator.doesRelationConform(leftValue, rightValue); if (doesAnyOfLeftValuesConform((Vector)leftValue, tempRight, session)) { return true; if (doValuesConform(leftValue, tempRight, session)) { return true; return doesAnyOfLeftValuesConform((Vector)leftValue, rightValue, session); return doValuesConform(leftValue, rightValue, session);
/** * Conform in-memory the two values. */ protected boolean doValuesConform(Object leftValue, Object rightValue, AbstractSession session) { // Check for object comparison. if (isObjectComparison(session)) { return doesObjectConform(leftValue, rightValue, session); } else { return this.operator.doesRelationConform(leftValue, rightValue); } }
Expression rightChild = ((RelationExpression)criteria).getSecondChild(); if (rightChild instanceof QueryKeyExpression) { subQuery.setReferenceClass(((QueryKeyExpression)rightChild).getDescriptor().getJavaClass());
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { ExpressionOperator realOperator = getPlatformOperator(printer.getPlatform()); Expression tempFirstChild = this.firstChild; Expression tempSecondChild = this.secondChild; realOperator.printJavaDuo(tempFirstChild, tempSecondChild, printer); }
return new RelationExpression(); } else if (this.nodeClass == ClassConstants.LogicalExpression_Class) { return new LogicalExpression();
mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true; mapping.writeFromAttributeIntoRow(value, primaryKeyRow, getSession()); return true;
/** * INTERNAL: * Modify this individual expression node to use outer joins wherever there are * equality operations between two field nodes. */ protected void convertNodeToUseOuterJoin() { if ((this.operator.getSelector() == ExpressionOperator.Equal) && allChildrenAreFields()) { setOperator(getOperator(ExpressionOperator.EqualOuterJoin)); } }