getDescriptor().getInheritancePolicy().appendWithAllSubclassesExpression(selectStatement);
/** * INTERNAL: * Return a select statement that will be used to query the class indicators required to query. * This is used in the abstract-multiple read. */ public SQLSelectStatement buildClassIndicatorSelectStatement(ObjectLevelReadQuery query) { SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.useDistinct(); selectStatement.addTable(classIndicatorField.getTable()); selectStatement.addField(getClassIndicatorField()); // 2612538 - the default size of IdentityHashtable (32) is appropriate IdentityHashtable clonedExpressions = new IdentityHashtable(); selectStatement.setWhereClause(((ExpressionQueryMechanism)query.getQueryMechanism()).buildBaseSelectionCriteria(false, clonedExpressions)); appendWithAllSubclassesExpression(selectStatement); selectStatement.setTranslationRow(query.getTranslationRow()); selectStatement.normalize(query.getSession(), getDescriptor(), clonedExpressions); ExpressionQueryMechanism m = (ExpressionQueryMechanism)query.getQueryMechanism(); return selectStatement; }
/** * Return the appropriate select statement containing the fields in the table. */ protected SQLSelectStatement buildNormalSelectStatement() { // From bug 2612185 Remember the identity hashtable used in cloning the selection criteria even in the normal case // for performance, in case subqueries need it, or for order by expressions. // 2612538 - the default size of IdentityHashtable (32) is appropriate IdentityHashtable clonedExpressions = new IdentityHashtable(); SQLSelectStatement selectStatement = buildBaseSelectStatement(false, clonedExpressions); // Case, normal read for branch inheritence class that reads subclasses all in its own table(s). if (getDescriptor().hasInheritance()) { getDescriptor().getInheritancePolicy().appendWithAllSubclassesExpression(selectStatement); } selectStatement.setFields(getSelectionFields(selectStatement, true)); selectStatement.setNonSelectFields(getNonSelectionFields()); selectStatement.normalize(getSession(), getDescriptor(), clonedExpressions); // Allow for joining indexes to be computed to ensure distinct rows ((ObjectLevelReadQuery)getQuery()).getJoinedAttributeManager().computeJoiningMappingIndexes(true, getSession(),0); return selectStatement; }