/** * INTERNAL: * Return if the represents an object comparison. */ protected boolean isObjectComparison() { int selector = this.operator.getSelector(); if (((selector != ExpressionOperator.IsNull) && (selector != ExpressionOperator.NotNull)) || (this.children.size() != 1)) { if (((selector != ExpressionOperator.InSubQuery) && (selector != ExpressionOperator.NotInSubQuery)) || (this.children.size() != 2)) { return false; } } Expression base = getBaseExpression(); //bug 384641 - check that directCollections are not treated as object comparisons return (base.isObjectExpression() && (!((ObjectExpression)base).isAttribute()) && !((ObjectExpression)base).isDirectCollection() ); }
/** * INTERNAL: * Return if the represents an object comparison. */ protected boolean isObjectComparison() { int selector = this.operator.getSelector(); if (((selector != ExpressionOperator.IsNull) && (selector != ExpressionOperator.NotNull)) || (this.children.size() != 1)) { if (((selector != ExpressionOperator.InSubQuery) && (selector != ExpressionOperator.NotInSubQuery)) || (this.children.size() != 2)) { return false; } } Expression base = getBaseExpression(); //bug 384641 - check that directCollections are not treated as object comparisons return (base.isObjectExpression() && (!((ObjectExpression)base).isAttribute()) && !((ObjectExpression)base).isDirectCollection() ); }
/** * INTERNAL: * Return if the represents an object comparison. */ protected boolean isObjectComparison() { if (this.children.size() != 1) { return false; } int selector = getOperator().getSelector(); if ((selector != ExpressionOperator.IsNull) && (selector != ExpressionOperator.NotNull)) { return false; } Expression base = getBaseExpression(); return (base.isObjectExpression() && (!((ObjectExpression)base).isAttribute())); }
/** * INTERNAL: * Return if the represents an object comparison. */ protected boolean isObjectComparison() { if (isObjectComparisonExpression == null) { // PERF: direct-access. if ((!this.firstChild.isObjectExpression()) || ((ObjectExpression)this.firstChild).isAttribute()) { isObjectComparisonExpression = Boolean.FALSE; } else { DatabaseMapping mapping = ((ObjectExpression)this.firstChild).getMapping(); if ((mapping != null) && (mapping.isDirectCollectionMapping()) && !(this.firstChild.isMapEntryExpression())) { isObjectComparisonExpression = Boolean.FALSE; } else { isObjectComparisonExpression = Boolean.valueOf(this.secondChild.isObjectExpression() || (this.secondChild.isValueExpression() || (this.secondChild.isFunctionExpression() && ((FunctionExpression)this.secondChild).operator.isAnyOrAll()))); } } } return isObjectComparisonExpression.booleanValue(); }
/** * Validate and prepare join expressions. */ public void prepareJoinExpressions(AbstractSession session) { // The prepareJoinExpression check for outer-joins to set this to true. setIsOuterJoinedAttributeQuery(false); for (int index = 0; index < getJoinedAttributeExpressions().size(); index++) { Expression expression = getJoinedAttributeExpressions().get(index); if(expression.isObjectExpression()) { ((ObjectExpression)expression).setShouldUseOuterJoinForMultitableInheritance(true); } prepareJoinExpression(expression, session); } for (int index = 0; index < getJoinedMappingExpressions().size(); index++) { Expression expression = getJoinedMappingExpressions().get(index); if(expression.isObjectExpression()) { ((ObjectExpression)expression).setShouldUseOuterJoinForMultitableInheritance(true); } prepareJoinExpression(expression, session); } }
/** * PUBLIC: * Specify the object expression to be joined in this query. * This allows the query results to be filtered based on the join to the object. * The object should define an on clause that defines the join condition. * This allows for two non-related objects to be joined. * * <p>Example: (select all employees that are a team leader)</p> * <pre> * ExpressionBuilder project = new ExpressionBuilder(Project.class); * ExpressionBuilder employee = new ExpressionBuilder(Employee.class); * ReadAllQuery query = new ReadAllQuery(Employee.class, employee); * query.addJoin(project.on(project.get("teamLeader").equal(employee))) * </pre> */ public void addNonFetchJoin(Expression target) { getNonFetchJoinAttributeExpressions().add(target); if (target.isObjectExpression() && ((ObjectExpression)target).shouldUseOuterJoin()) { this.setShouldBuildNullForNullPk(true); } // Bug 2804042 Must un-prepare if prepared as the SQL may change. // Joined attributes are now calculated in prePrepare. setIsPrePrepared(false); }
/** * PUBLIC: * Specify the object expression to be joined in this query. * This allows the query results to be filtered based on the join to the object. * The object should define an on clause that defines the join condition. * This allows for two non-related objects to be joined. * * <p>Example: (select all employees that are a team leader)</p> * <pre> * ExpressionBuilder project = new ExpressionBuilder(Project.class); * ExpressionBuilder employee = new ExpressionBuilder(Employee.class); * ReadAllQuery query = new ReadAllQuery(Employee.class, employee); * query.addJoin(project.on(project.get("teamLeader").equal(employee))) * </pre> */ public void addNonFetchJoin(Expression target) { getNonFetchJoinAttributeExpressions().add(target); if (target.isObjectExpression() && ((ObjectExpression)target).shouldUseOuterJoin()) { this.setShouldBuildNullForNullPk(true); } // Bug 2804042 Must un-prepare if prepared as the SQL may change. // Joined attributes are now calculated in prePrepare. setIsPrePrepared(false); }
public void add(Expression expression) { if (!contains(expression)) { if (expression.isObjectExpression()) { Expression baseExpression = resolveBaseExpression(expression); if (baseExpression != null && !baseExpression.isExpressionBuilder()) { add(baseExpression); ExpressionNode baseNode = findExpressionNode(baseExpression); ExpressionNode node = new ExpressionNode(expression, indexOfExpression(expression)); baseNode.addChild(node); index.put(expression, node); } else { ExpressionNode node = new ExpressionNode(expression, indexOfExpression(expression)); roots.add(node); index.put(expression, node); } } else { ExpressionNode node = new ExpressionNode(expression, indexOfExpression(expression)); roots.add(node); index.put(expression, node); } } }
if (expression.isObjectExpression()) { ObjectExpression joinedAttribute = (ObjectExpression)expression;
if (expression.isObjectExpression()) { ObjectExpression joinedAttribute = (ObjectExpression)expression;
if (expression.isObjectExpression()) { ObjectExpression joinedAttribute = (ObjectExpression)expression;
if(next.isObjectExpression()) { ObjectExpression objectExp = (ObjectExpression)next; objectExp.writeForUpdateOfFields(printer, statement);
if ((value != null) && !(value instanceof Collection) && (queryKey != null) && queryKey.isObjectExpression()) { DatabaseMapping mapping = ((ObjectExpression) queryKey).getMapping(); if (mapping != null) {
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ @Override public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) { Expression twistedBase = this.baseExpression.twistedForBaseAndContext(newBase, context, oldBase); DatabaseField field = getField(); ClassDescriptor descriptor = null; // Check for possible table per class rebuild and translate fields to correct table. // TODO: JPA also allows for field to be renamed in subclasses, this needs to account for that (never has...). if (this.baseExpression.isExpressionBuilder() && newBase.isObjectExpression() && ((this.baseExpression == oldBase) || (oldBase == null))) { if (((ObjectExpression)newBase).getSession() != null) { descriptor = ((ObjectExpression)newBase).getDescriptor(); } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); field.setTable(descriptor.getDefaultTable()); } } return twistedBase.getField(field); }
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ @Override public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) { Expression twistedBase = this.baseExpression.twistedForBaseAndContext(newBase, context, oldBase); DatabaseField field = getField(); ClassDescriptor descriptor = null; // Check for possible table per class rebuild and translate fields to correct table. // TODO: JPA also allows for field to be renamed in subclasses, this needs to account for that (never has...). if (this.baseExpression.isExpressionBuilder() && newBase.isObjectExpression() && ((this.baseExpression == oldBase) || (oldBase == null))) { if (((ObjectExpression)newBase).getSession() != null) { descriptor = ((ObjectExpression)newBase).getDescriptor(); } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); field.setTable(descriptor.getDefaultTable()); } } return twistedBase.getField(field); }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ public Expression rebuildOn(Expression newBase) { DatabaseField field = getField(); ClassDescriptor descriptor = null; // Check for possible table per class rebuild and translate fields to correct table. // TODO: JPA also allows for field to be renamed in subclasses, this needs to account for that (never has...). if (getBaseExpression().isExpressionBuilder() && newBase.isObjectExpression()) { if (((ObjectExpression)newBase).getSession() != null) { descriptor = ((ObjectExpression)newBase).getDescriptor(); } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); field.setTable(descriptor.getDefaultTable()); } } FieldExpression expression = new FieldExpression(field, getBaseExpression().rebuildOn(newBase)); expression.setSelectIfOrderedBy(selectIfOrderedBy()); return expression; }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ public Expression rebuildOn(Expression newBase) { DatabaseField field = getField(); ClassDescriptor descriptor = null; // Check for possible table per class rebuild and translate fields to correct table. // TODO: JPA also allows for field to be renamed in subclasses, this needs to account for that (never has...). if (getBaseExpression().isExpressionBuilder() && newBase.isObjectExpression()) { if (((ObjectExpression)newBase).getSession() != null) { descriptor = ((ObjectExpression)newBase).getDescriptor(); } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); field.setTable(descriptor.getDefaultTable()); } } FieldExpression expression = new FieldExpression(field, getBaseExpression().rebuildOn(newBase)); expression.setSelectIfOrderedBy(selectIfOrderedBy()); return expression; }
if(next.isObjectExpression()) { ObjectExpression objectExp = (ObjectExpression)next; objectExp.writeForUpdateOfFields(printer, statement);
if(next.isObjectExpression()) { ObjectExpression objectExp = (ObjectExpression)next; objectExp.writeForUpdateOfFields(printer, statement);
&& mappingExpression.getBaseExpression().isObjectExpression() && (!mappingExpression.shouldUseOuterJoin())) {