private String getPrimaryKeyAliases(SQLSelectStatement statement) { StringBuilder builder = new StringBuilder(); Iterator<DatabaseField> iterator = statement.getQuery().getDescriptor().getPrimaryKeyFields().iterator(); while (iterator.hasNext()) { builder.append(statement.getAliasFor(iterator.next())); if(iterator.hasNext()) { builder.append(','); } } return builder.toString(); }
private void printLockStartWithPrimaryKeyFields(SQLSelectStatement statement, ExpressionSQLPrinter printer) { printer.printString(LOCK_START_PREFIX); Iterator<DatabaseField> iterator = statement.getQuery().getDescriptor().getPrimaryKeyFields().iterator(); while (iterator.hasNext()) { DatabaseField field = iterator.next(); DatabaseTable alias = statement.getExpressionBuilder().aliasForTable(field.getTable()); printer.printField(field, alias); if(iterator.hasNext()) { printer.printString(","); } } printer.printString(LOCK_START_SUFFIX); }
/** * INTERNAL: * Allow the mapping the do any further batch preparation. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); // Force a distinct to filter out m-1 duplicates. // Only set if really a m-1, not a 1-1 if (!this.isOneToOneRelationship && ((ObjectLevelReadQuery)batchQuery).getBatchFetchPolicy().isJOIN()) { if (!((ObjectLevelReadQuery)batchQuery).isDistinctComputed() && (batchQuery.getSession().getPlatform().isLobCompatibleWithDistinct() || !Helper.hasLob(batchQuery.getDescriptor().getSelectionFields((ObjectLevelReadQuery)batchQuery)))) { ((ObjectLevelReadQuery)batchQuery).useDistinct(); } } if (this.mechanism != null) { this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); } }
/** * INTERNAL: * Allow the mapping the do any further batch preparation. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); // Force a distinct to filter out m-1 duplicates. // Only set if really a m-1, not a 1-1 if (!this.isOneToOneRelationship && ((ObjectLevelReadQuery)batchQuery).getBatchFetchPolicy().isJOIN()) { if (!((ObjectLevelReadQuery)batchQuery).isDistinctComputed() && (batchQuery.getSession().getPlatform().isLobCompatibleWithDistinct() || !Helper.hasLob(batchQuery.getDescriptor().getSelectionFields((ObjectLevelReadQuery)batchQuery)))) { ((ObjectLevelReadQuery)batchQuery).useDistinct(); } } if (this.mechanism != null) { this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); } }
if (getQuery().getDescriptor().hasInheritance() && (getQuery().getDescriptor().getInheritancePolicy().getWithAllSubclassesExpression() != null)) { Expression branchIndicator = getQuery().getDescriptor().getInheritancePolicy().getWithAllSubclassesExpression(); if ((branchIndicator != null) && (selectStatement.getWhereClause() != null)) { selectStatement.setWhereClause(selectStatement.getWhereClause().and(branchIndicator)); selectStatement.setTables((Vector)getQuery().getDescriptor().getTables().clone()); } else { selectStatement.computeDistinct(); if (selectStatement.shouldDistinctBeUsed() && (getQuery().getDescriptor().getPrimaryKeyFields().size() == 1)) { selectStatement.addField(buildCountDistinctExpression(getQuery().getDescriptor().getPrimaryKeyFields(), ((ReadAllQuery)getQuery()).getExpressionBuilder())); } else { selectStatement.addField(((ReadAllQuery)getQuery()).getExpressionBuilder().count()); selectStatement.normalize(getSession(), getQuery().getDescriptor(), clonedExpressions);
selectStatement.setWhereClause(((ExpressionQueryMechanism)this.query.getQueryMechanism()).buildBaseSelectionCriteria(false, clonedExpressions)); ClassDescriptor descriptor = this.query.getDescriptor();
selectStatement.setWhereClause(((ExpressionQueryMechanism)this.query.getQueryMechanism()).buildBaseSelectionCriteria(false, clonedExpressions)); ClassDescriptor descriptor = this.query.getDescriptor();
if (targetQuery.isObjectLevelReadQuery() && targetQuery.getDescriptor().hasFetchGroupManager()) { FetchGroup sourceFG = sourceQuery.getExecutionFetchGroup(this.getDescriptor()); if (sourceFG != null) {
if (targetQuery.isObjectLevelReadQuery() && targetQuery.getDescriptor().hasFetchGroupManager()) { FetchGroup sourceFG = sourceQuery.getExecutionFetchGroup(this.getDescriptor()); if (sourceFG != null) {