/** * INTERNAL: * Indicates that RelationExpression.normalize method shouldn't attempt * optimize normalization by not normalizing this. */ public boolean isNormalizationRequired() { return shouldQueryToManyRelationship() || // For bug 2718460, some QueryKeyExpressions have a query key but no mapping. // An example is the "back-ref" query key for batch reads. Must not // attempt the optimization for these. getMapping() == null || // For bug 5234283: WRONG =* SQL FOR LEFT JOIN ON DERBY AND DB2 PLATFORMS // Caused by QueryKeyExpression never been normilized. // The condition should be kept in sync with condtions in normalize method // that trigger adding to normalizer.getStatement().getOuterJoin... ((shouldUseOuterJoin() || isUsingOuterJoinForMultitableInheritance()) && !getSession().getPlatform().shouldPrintOuterJoinInWhereClause()) || (shouldUseOuterJoin() && getSession().getPlatform().isInformixOuterJoin()); }
public void iterate(Expression expression) { if (expression.isQueryKeyExpression() && ((QueryKeyExpression)expression).shouldQueryToManyRelationship()) { // Aggregate should only use distinct as specified by the user. if (!isDistinctComputed()) { useDistinct(); } } } };
@Override public void iterate(Expression expression) { if (expression.isQueryKeyExpression() && ((QueryKeyExpression)expression).shouldQueryToManyRelationship()) { // Aggregate should only use distinct as specified by the user. if (!isDistinctComputed()) { useDistinct(); } } } };
public void iterate(Expression expression) { if (expression.isQueryKeyExpression() && ((QueryKeyExpression)expression).shouldQueryToManyRelationship()) { // Aggregate should only use distinct as specified by the user. if (!isDistinctComputed()) { useDistinct(); } } } };
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } QueryKeyExpression expression = (QueryKeyExpression) object; // Return false for anyOf expressions, as equality is unknown. if (shouldQueryToManyRelationship() || expression.shouldQueryToManyRelationship()) { return false; } return ((getName() == expression.getName()) || ((getName() != null) && getName().equals(expression.getName()))); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ @Override public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } QueryKeyExpression expression = (QueryKeyExpression) object; // Return false for anyOf expressions, as equality is unknown. if (shouldQueryToManyRelationship() || expression.shouldQueryToManyRelationship()) { return false; } return ((getName() == expression.getName()) || ((getName() != null) && getName().equals(expression.getName()))); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ @Override public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } QueryKeyExpression expression = (QueryKeyExpression) object; // Return false for anyOf expressions, as equality is unknown. if (shouldQueryToManyRelationship() || expression.shouldQueryToManyRelationship()) { return false; } return ((getName() == expression.getName()) || ((getName() != null) && getName().equals(expression.getName()))); }
/** * INTERNAL: * Print java for project class generation */ @Override public void printJava(ExpressionJavaPrinter printer) { this.baseExpression.printJava(printer); if (!shouldUseOuterJoin()) { if (!shouldQueryToManyRelationship()) { printer.printString(".get("); } else { printer.printString(".anyOf("); } } else { if (!shouldQueryToManyRelationship()) { printer.printString(".getAllowingNull("); } else { printer.printString(".anyOfAllowingNone("); } } printer.printString("\"" + getName() + "\")"); }
/** * INTERNAL: * Print java for project class generation */ @Override public void printJava(ExpressionJavaPrinter printer) { this.baseExpression.printJava(printer); if (!shouldUseOuterJoin()) { if (!shouldQueryToManyRelationship()) { printer.printString(".get("); } else { printer.printString(".anyOf("); } } else { if (!shouldQueryToManyRelationship()) { printer.printString(".getAllowingNull("); } else { printer.printString(".anyOfAllowingNone("); } } printer.printString("\"" + getName() + "\")"); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { getBaseExpression().printJava(printer); if (!shouldUseOuterJoin()) { if (!shouldQueryToManyRelationship()) { printer.printString(".get("); } else { printer.printString(".anyOf("); } } else { if (!shouldQueryToManyRelationship()) { printer.printString(".getAllowingNull("); } else { printer.printString(".anyOfAllowingNone("); } } printer.printString("\"" + getName() + "\")"); }
/** * INTERNAL: */ public Vector getOwnedTables() { if ((getMapping() != null) && getMapping().isNestedTableMapping()) { Vector nestedTable = null; if (shouldQueryToManyRelationship()) { nestedTable = (Vector)super.getOwnedTables().clone(); } else { nestedTable = new Vector(1); } nestedTable.addElement(new NestedTable(this)); return nestedTable; } if ((getMapping() != null) && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) { return null; } return super.getOwnedTables(); }
/** * INTERNAL: */ @Override public List<DatabaseTable> getOwnedTables() { if ((getMapping() != null) && getMapping().isNestedTableMapping()) { List<DatabaseTable> nestedTable = null; if (shouldQueryToManyRelationship()) { nestedTable = new ArrayList(super.getOwnedTables()); } else { nestedTable = new ArrayList(1); } nestedTable.add(new NestedTable(this)); return nestedTable; } if ((getMapping() != null) && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) { return null; } return super.getOwnedTables(); }
/** * INTERNAL: */ @Override public List<DatabaseTable> getOwnedTables() { if ((getMapping() != null) && getMapping().isNestedTableMapping()) { List<DatabaseTable> nestedTable = null; if (shouldQueryToManyRelationship()) { nestedTable = new ArrayList(super.getOwnedTables()); } else { nestedTable = new ArrayList(1); } nestedTable.add(new NestedTable(this)); return nestedTable; } if ((getMapping() != null) && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) { return null; } return super.getOwnedTables(); }
if ((!shouldQueryToManyRelationship()) && qkIsToMany && (!isNestedMapping)) { throw QueryException.invalidUseOfToManyQueryKeyInExpression(theOneThatsNotNull); if (shouldQueryToManyRelationship() && !qkIsToMany) { throw QueryException.invalidUseOfAnyOfInExpression(theOneThatsNotNull);
if ((!shouldQueryToManyRelationship()) && qkIsToMany && (!isNestedMapping)) { throw QueryException.invalidUseOfToManyQueryKeyInExpression(theOneThatsNotNull); if (shouldQueryToManyRelationship() && !qkIsToMany) { throw QueryException.invalidUseOfAnyOfInExpression(theOneThatsNotNull);
/** * Validate and prepare the join expression. */ protected void prepareJoinExpression(Expression expression, AbstractSession session) { // Must be query key expression. if (!expression.isQueryKeyExpression()) { throw QueryException.mappingForExpressionDoesNotSupportJoining(expression); } QueryKeyExpression objectExpression = (QueryKeyExpression)expression; // Expression may not have been initialized. objectExpression.getBuilder().setSession(session.getRootSession(null)); if (objectExpression.getBuilder().getQueryClass() == null){ objectExpression.getBuilder().setQueryClass(this.descriptor.getJavaClass()); } // Can only join relationships. if ((objectExpression.getMapping() == null) || (!objectExpression.getMapping().isJoiningSupported())) { throw QueryException.mappingForExpressionDoesNotSupportJoining(objectExpression); } // Search if any of the expression traverse a 1-m. ObjectExpression baseExpression = objectExpression; while (!baseExpression.isExpressionBuilder()) { if (((QueryKeyExpression)baseExpression).shouldQueryToManyRelationship()) { setIsToManyJoinQuery(true); } if (baseExpression.shouldUseOuterJoin()) { setIsOuterJoinedAttributeQuery(true); } baseExpression = (ObjectExpression)baseExpression.getBaseExpression(); } }
if ((!shouldQueryToManyRelationship()) && qkIsToMany && (!isNestedMapping)) { throw QueryException.invalidUseOfToManyQueryKeyInExpression(theOneThatsNotNull); if (shouldQueryToManyRelationship() && !qkIsToMany) { throw QueryException.invalidUseOfAnyOfInExpression(theOneThatsNotNull);
if (((QueryKeyExpression)baseExpression).shouldQueryToManyRelationship()) { setIsToManyJoinQuery(true);
if (((QueryKeyExpression)expression).shouldQueryToManyRelationship()) { getJoinedAttributeManager().setIsToManyJoinQuery(true);
if (((QueryKeyExpression)baseExpression).shouldQueryToManyRelationship()) { setIsToManyJoinQuery(true);