/** * 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); }
readQuery.setShouldBuildNullForNullPk(this.hasOneToOneSelected(context));
readQuery.setShouldBuildNullForNullPk(this.hasOneToOneSelected(context));
readQuery.setShouldBuildNullForNullPk(this.hasOneToOneSelected(context));
void visitAbstractSelectClause(AbstractSelectClause expression) { // DISTINCT if (expression.hasDistinct()) { CountFunctionVisitor visitor = new CountFunctionVisitor(); expression.accept(visitor); if (!visitor.hasCountFunction) { query.useDistinct(); } } // Indicate on the query if "return null if primary key null". // This means we want nulls returned if we expect an outer join // True: SELECT employee.address FROM ..... // Simple 1:1 // True: SELECT a.b.c.d FROM ..... // where a->b, b->c and c->d are all 1:1. // False: SELECT OBJECT(employee) FROM ..... // simple SELECT // False: SELECT phoneNumber.areaCode FROM ..... // direct-to-field OneToOneSelectedVisitor visitor = new OneToOneSelectedVisitor(); expression.accept(visitor); query.setShouldBuildNullForNullPk(visitor.oneToOneSelected); // Now visit the select expression expression.getSelectExpression().accept(this); }
void visitAbstractSelectClause(AbstractSelectClause expression) { // DISTINCT if (expression.hasDistinct()) { CountFunctionVisitor visitor = new CountFunctionVisitor(); expression.accept(visitor); if (!visitor.hasCountFunction) { query.useDistinct(); } } // Indicate on the query if "return null if primary key null". // This means we want nulls returned if we expect an outer join // True: SELECT employee.address FROM ..... // Simple 1:1 // True: SELECT a.b.c.d FROM ..... // where a->b, b->c and c->d are all 1:1. // False: SELECT OBJECT(employee) FROM ..... // simple SELECT // False: SELECT phoneNumber.areaCode FROM ..... // direct-to-field OneToOneSelectedVisitor visitor = new OneToOneSelectedVisitor(); expression.accept(visitor); query.setShouldBuildNullForNullPk(visitor.oneToOneSelected); // Now visit the select expression expression.getSelectExpression().accept(this); }
nestedQuery.setShouldBuildNullForNullPk(true);
nestedQuery.setShouldBuildNullForNullPk(true);
nestedQuery.setShouldBuildNullForNullPk(true);