/** * INTERNAL: * Called when the selection query is being initialized to add any required additional fields to the * query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ if (baseExpression == null){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField((DatabaseField)keyField.clone()); ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addTable((DatabaseTable)keyField.getTable().clone()); } else { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getTable((DatabaseTable)keyField.getTable()).getField(keyField)); } }
/** * INTERNAL: * Add the index field to the query. */ @Override public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression) { if (this.listOrderField != null) { if (selectionQuery.isObjectLevelReadQuery()) { ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(this.listOrderField)); } else { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getField(this.listOrderField)); } } } }
protected void initializeSelectionStatement(AbstractSession session) { SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(getReferenceTable()); statement.addField((DatabaseField)getDirectField().clone()); statement.setWhereClause(getSelectionCriteria()); if(listOrderField != null) { Expression expField = getListOrderFieldExpression(statement.getBuilder()); statement.addField(expField); } statement.normalize(session, null); getSelectionQuery().setSQLStatement(statement); }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getForeignKeyFields()) { if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(field); } } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getForeignKeyFields()) { if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(field); } } }
/** * INTERNAL: * Initialize lockRelationTableQuery. */ protected void initializeLockRelationTableQuery(AbstractSession session, ForeignReferenceMapping mapping, Expression startCriteria) { lockRelationTableQuery = new DirectReadQuery(); Expression criteria = buildSelectionCriteriaAndAddFieldsToQueryInternal(mapping, startCriteria, false, false); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField(this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause(criteria); statement.normalize(session, null); lockRelationTableQuery.setSQLStatement(statement); lockRelationTableQuery.setSessionName(session.getName()); }
/** * INTERNAL: * Initialize lockRelationTableQuery. */ protected void initializeLockRelationTableQuery(AbstractSession session, ForeignReferenceMapping mapping, Expression startCriteria) { lockRelationTableQuery = new DirectReadQuery(); Expression criteria = buildSelectionCriteriaAndAddFieldsToQueryInternal(mapping, startCriteria, false, false); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField((DatabaseField)this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause(criteria); statement.normalize(session, null); lockRelationTableQuery.setSQLStatement(statement); lockRelationTableQuery.setSessionName(session.getName()); }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(getField())); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getField(getField())); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(getField())); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getField(getField())); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the selection query is being initialized to add the fields for the map key to the query */ @Override public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getReferenceDescriptor().getAllFields()) { if (selectionQuery.isObjectLevelReadQuery()) { ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()) { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getField(field)); } } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the selection query is being initialized to add the fields for the map key to the query */ @Override public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getReferenceDescriptor().getAllFields()) { if (selectionQuery.isObjectLevelReadQuery()) { ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()) { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getField(field)); } } }
/** * When distinct is used with order by the ordered fields must be in the select clause. */ protected void addOrderByExpressionToSelectForDistinct() { for (Expression orderExpression : getOrderByExpressions()) { Expression fieldExpression = orderExpression; while (fieldExpression.isFunctionExpression() && (fieldExpression.getOperator().isOrderOperator())) { fieldExpression = ((FunctionExpression)fieldExpression).getBaseExpression(); } // Changed to call a method to loop through the fields vector and check each element // individually. Jon D. May 4, 2000 for pr 7811 if ((fieldExpression.selectIfOrderedBy()) && !fieldsContainField(getFields(), fieldExpression)) { addField(fieldExpression); } } }
/** * INTERNAL: * Returns a query that */ ReadQuery getLockRelationTableQueryClone(AbstractSession session, short lockMode) { DirectReadQuery lockRelationTableQueryClone = (DirectReadQuery)lockRelationTableQuery.clone(); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField(this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause((Expression)lockRelationTableQuery.getSelectionCriteria().clone()); statement.setLockingClause(new ForUpdateClause(lockMode)); statement.normalize(session, null); lockRelationTableQueryClone.setSQLStatement(statement); lockRelationTableQueryClone.setIsExecutionClone(true); return lockRelationTableQueryClone; }
/** * INTERNAL: * Returns a query that */ ReadQuery getLockRelationTableQueryClone(AbstractSession session, short lockMode) { DirectReadQuery lockRelationTableQueryClone = (DirectReadQuery)lockRelationTableQuery.clone(); SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(this.relationTable); statement.addField(this.sourceRelationKeyFields.get(0).clone()); statement.setWhereClause((Expression)lockRelationTableQuery.getSelectionCriteria().clone()); statement.setLockingClause(new ForUpdateClause(lockMode)); statement.normalize(session, null); lockRelationTableQueryClone.setSQLStatement(statement); lockRelationTableQueryClone.setIsExecutionClone(true); return lockRelationTableQueryClone; }
protected void initializeSelectionStatement(AbstractSession session) { SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(getReferenceTable()); statement.addField(getDirectField().clone()); statement.setWhereClause(getSelectionCriteria()); statement.setOrderByExpressions(orderByExpressions); getSelectionQuery().setSQLStatement(statement); getContainerPolicy().addAdditionalFieldsToQuery(selectionQuery, getAdditionalFieldsBaseExpression(getSelectionQuery())); statement.normalize(session, null); }
protected void initializeSelectionStatement(AbstractSession session) { SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(getReferenceTable()); statement.addField(getDirectField().clone()); statement.setWhereClause(getSelectionCriteria()); statement.setOrderByExpressions(orderByExpressions); getSelectionQuery().setSQLStatement(statement); getContainerPolicy().addAdditionalFieldsToQuery(selectionQuery, getAdditionalFieldsBaseExpression(getSelectionQuery())); statement.normalize(session, null); }
@Override protected void initializeSelectionStatement(AbstractSession session) { if (this.selectionQuery.isReadAllQuery()){ ((ReadAllQuery)this.selectionQuery).addAdditionalField(getDirectField().clone()); } else { SQLSelectStatement statement = (SQLSelectStatement)this.selectionQuery.getSQLStatement(); statement.addTable(getReferenceTable()); statement.addField(getDirectField().clone()); getContainerPolicy().addAdditionalFieldsToQuery(this.selectionQuery, getAdditionalFieldsBaseExpression(this.selectionQuery)); statement.normalize(session, null); } if (this.selectionQuery.isDirectReadQuery()){ ((DirectReadQuery)this.selectionQuery).setResultType(DataReadQuery.MAP); } }
/** * Return the appropriate select statement to perform a does exist check * @param field fields for does exist check. */ protected SQLSelectStatement buildSelectStatementForDoesExist(DatabaseField field) { // Build appropriate select statement SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.addField(field); selectStatement.setWhereClause(((Expression)getDescriptor().getObjectBuilder().getPrimaryKeyExpression().clone()).and(getDescriptor().getQueryManager().getAdditionalJoinExpression())); selectStatement.setTranslationRow(getTranslationRow()); selectStatement.normalize(getSession(), getQuery().getDescriptor()); selectStatement.setHintString(getQuery().getHintString()); return selectStatement; }
/** * Return the appropriate select statement to perform a does exist check * @param field fields for does exist check. */ protected SQLSelectStatement buildSelectStatementForDoesExist(DatabaseField field) { // Build appropriate select statement SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.addField(field); selectStatement.setWhereClause(((Expression)getDescriptor().getObjectBuilder().getPrimaryKeyExpression().clone()).and(getDescriptor().getQueryManager().getAdditionalJoinExpression())); selectStatement.setTranslationRow(getTranslationRow()); selectStatement.normalize(getSession(), getQuery().getDescriptor()); selectStatement.setHintString(getQuery().getHintString()); return selectStatement; }
/** * Return the appropriate select statement to perform a does exist check * @param field fields for does exist check. */ protected SQLSelectStatement buildSelectStatementForDoesExist(DatabaseField field) { // Build appropriate select statement SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.addField(field); selectStatement.setWhereClause(((Expression)getDescriptor().getObjectBuilder().getPrimaryKeyExpression().clone()).and(getDescriptor().getQueryManager().getAdditionalJoinExpression())); selectStatement.setTranslationRow(getTranslationRow()); selectStatement.normalize(getSession(), getQuery().getDescriptor()); selectStatement.setHintString(getQuery().getHintString()); return selectStatement; }