/** * Used by DeleteAllQuery to create DeleteStatement in a simple case * when selectionCriteria==null. */ protected SQLDeleteStatement buildDeleteStatementForDeleteAllQuery(DatabaseTable table, Expression inheritanceExpression) { SQLDeleteStatement deleteStatement = new SQLDeleteStatement(); if(inheritanceExpression != null) { deleteStatement.setWhereClause((Expression)inheritanceExpression.clone()); } deleteStatement.setTable(table); deleteStatement.setTranslationRow(getTranslationRow()); return deleteStatement; }
/** * INTERNAL: * Clone the query, including its selection criteria. * <p> * Normally selection criteria are not cloned here as they are cloned * later on during prepare. */ public Object deepClone() { ObjectLevelReadQuery clone = (ObjectLevelReadQuery)clone(); if (getSelectionCriteria() != null) { clone.setSelectionCriteria((Expression)getSelectionCriteria().clone()); } else if (defaultBuilder != null) { clone.defaultBuilder = (ExpressionBuilder)defaultBuilder.clone(); } return clone; }
selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass());
/** * INTERNAL: * Append the branch with all subclasses expression to the statement. */ public void appendWithAllSubclassesExpression(SQLSelectStatement selectStatement) { if (getWithAllSubclassesExpression() != null) { // For Flashback: Must always rebuild with simple expression on right. if (selectStatement.getWhereClause() == null) { selectStatement.setWhereClause((Expression)getWithAllSubclassesExpression().clone()); } else { selectStatement.setWhereClause(selectStatement.getWhereClause().and(getWithAllSubclassesExpression())); } } }
DatabaseField targetField = (DatabaseField)((OneToOneMapping)mapping).getSourceToTargetKeyFields().get(fields.elementAt(i)); if(valueObject instanceof Expression) { values.add(((Expression)((Expression)valueObject).clone()).getField(targetField)); } else { values.add(((OneToOneMapping)mapping).getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(valueObject, targetField, getSession())); Expression valueClone = (Expression)value.clone(); valueClone.getBuilder().setSession(getSession()); valueClone.getBuilder().setQueryClass(getQuery().getReferenceClass());
selectionCriteriaClone = (Expression)selectionCriteria.clone(); selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass);
sqlStatement.addTable(table); if (table == getDescriptor().getTables().firstElement()) { sqlStatement.setWhereClause((Expression)getPrimaryKeyExpression().clone()); } else { sqlStatement.setWhereClause(buildPrimaryKeyExpression(table));
if(inheritanceExpression != null) { if (selectStatement.getWhereClause() == null) { selectStatement.setWhereClause((Expression)inheritanceExpression.clone()); } else { selectStatement.setWhereClause(selectStatement.getWhereClause().and(inheritanceExpression));
protected SQLSelectStatement createSQLSelectStatementForModifyAll(Expression whereClause, Expression inheritanceExpression, ClassDescriptor desc, boolean useCustomaryInheritanceExpression) { ExpressionBuilder builder; if(whereClause != null) { whereClause = (Expression)whereClause.clone(); builder = whereClause.getBuilder(); } else { builder = new ExpressionBuilder(); } ReportQuery reportQuery = new ReportQuery(desc.getJavaClass(), builder); reportQuery.setDescriptor(desc); reportQuery.setShouldRetrieveFirstPrimaryKey(true); reportQuery.setSelectionCriteria(whereClause); reportQuery.setSession(getSession()); return ((ExpressionQueryMechanism)reportQuery.getQueryMechanism()).buildReportQuerySelectStatement(false, useCustomaryInheritanceExpression, inheritanceExpression); }
/** * Return the appropriate select statement to perform a does exist check * @param fields - 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()); return selectStatement; }
selectionCriteriaClone = (Expression)selectionCriteria.clone(); selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass);
deleteAllStatement.setInheritanceExpression((Expression)inheritanceExpression.clone());
/** * INTERNAL: * Build a select statement for all subclasses on the view using the same * selection criteria as the query. */ public SQLSelectStatement buildViewSelectStatement(ObjectLevelReadQuery query) { // 2612538 - the default size of IdentityHashtable (32) is appropriate IdentityHashtable clonedExpressions = new IdentityHashtable(); ExpressionQueryMechanism mechanism = (ExpressionQueryMechanism)query.getQueryMechanism(); // CR#3166555 - Have the mechanism build the statement to avoid duplicating code and ensure that lock-mode, hints, hierarchical, etc. are set. SQLSelectStatement selectStatement = mechanism.buildBaseSelectStatement(false, clonedExpressions); selectStatement.setTables(oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1)); selectStatement.addTable(getReadAllSubclassesView()); // Case, normal read for branch inheritence class that reads subclasses all in its own table(s). if (getWithAllSubclassesExpression() != null) { Expression branchIndicator = (Expression)getWithAllSubclassesExpression().clone(); if (branchIndicator != null) { selectStatement.setWhereClause(branchIndicator.and(selectStatement.getWhereClause())); } } selectStatement.setFields(mechanism.getSelectionFields(selectStatement, true)); selectStatement.normalizeForView(query.getSession(), getDescriptor(), clonedExpressions); // Allow for joining indexes to be computed to ensure distinct rows ((ObjectLevelReadQuery)query).getJoinedAttributeManager().computeJoiningMappingIndexes(false, query.getSession(), 0); return selectStatement; }
selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass());
/** * Return the appropriate select statement containing the fields in the table. * This is used as a second read to a concrete class with subclasses in an abstract-multiple table read. */ protected SQLSelectStatement buildConcreteSelectStatement() { // 2612538 - the default size of IdentityHashtable (32) is appropriate IdentityHashtable clonedExpressions = new IdentityHashtable(); SQLSelectStatement selectStatement = buildBaseSelectStatement(false, clonedExpressions); // Case of class with subclasses that also has instances on abstract-multiple table read. if (getDescriptor().hasInheritance() && getDescriptor().getInheritancePolicy().shouldReadSubclasses()) { Expression concrete = (Expression)getDescriptor().getInheritancePolicy().getOnlyInstancesExpression(); if ((concrete != null) && (selectStatement.getWhereClause() != null)) { selectStatement.setWhereClause(selectStatement.getWhereClause().and(concrete)); } else if (concrete != null) { selectStatement.setWhereClause((Expression)concrete.clone()); } } selectStatement.setFields(getSelectionFields(selectStatement, false)); selectStatement.normalize(getSession(), getDescriptor(), clonedExpressions); // Allow for joining indexes to be computed to ensure distinct rows ((ObjectLevelReadQuery)getQuery()).getJoinedAttributeManager().computeJoiningMappingIndexes(false, getSession(), 0); return selectStatement; }
expression = (Expression)additionalJoin.clone(); } else { if (query.isObjectLevelReadQuery()){