/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); localBase = localBase.copiedVersionFrom(alreadyDone); }
/** * INTERNAL: * Clone the expression maintaining clone identity in the inter-connected expression graph. */ public Object clone() { // 2612538 - the default size of IdentityHashtable (32) is appropriate Dictionary alreadyDone = new IdentityHashtable(); return copiedVersionFrom(alreadyDone); }
public Vector copyCollection(Vector in, Dictionary alreadyDone) { if (in == null) { return null; } Vector result = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(in.size()); for (Enumeration e = in.elements(); e.hasMoreElements();) { Expression exp = (Expression)e.nextElement(); result.addElement(exp.copiedVersionFrom(alreadyDone)); } return result; }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); localBase = localBase.copiedVersionFrom(alreadyDone); }
/** * This method return the clones of the given expressions. * * @param originalExpressions * @param clonedExpressions * @return Vector */ private Vector cloneExpressions(Vector originalExpressions,Dictionary clonedExpressions){ if(originalExpressions==null || originalExpressions.size()==0){ return originalExpressions; } Vector newExpressions = new Vector(originalExpressions.size()); Iterator i = originalExpressions.iterator(); while (i.hasNext()){ Expression e = (Expression)i.next(); newExpressions.add(e.copiedVersionFrom(clonedExpressions)); } return newExpressions; }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); baseExpression = baseExpression.copiedVersionFrom(alreadyDone); Vector oldChildren = children; children = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); for (int i = 0; i < oldChildren.size(); i++) { addChild((Expression)(((Expression)oldChildren.elementAt(i)).copiedVersionFrom(alreadyDone))); } }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree. * This method will rebuildOn the receiver even it is a parallel select or a * sub select: it will not replace every base with newBase. * Also it will rebuild using anyOf as appropriate not get. * @see oracle.toplink.essentials.mappings.ForeignReferenceMapping#batchedValueFromRow * @see #rebuildOn(Expression) * @bug 2637484 INVALID QUERY KEY EXCEPTION THROWN USING BATCH READS AND PARALLEL EXPRESSIONS * @bug 2612567 CR4298- NULLPOINTEREXCEPTION WHEN USING SUBQUERY AND BATCH READING IN 4.6 * @bug 2612140 CR2973- BATCHATTRIBUTE QUERIES WILL FAIL WHEN THE INITIAL QUERY HAS A SUBQUERY * @bug 2720149 INVALID SQL WHEN USING BATCH READS AND MULTIPLE ANYOFS */ public Expression cloneUsing(Expression newBase) { // 2612538 - the default size of IdentityHashtable (32) is appropriate Dictionary alreadyDone = new IdentityHashtable(); // cloneUsing is identical to cloning save that the primary builder // will be replaced not with its clone but with newBase. // ExpressionBuilder.registerIn() will check for this newBase with // alreadyDone.get(alreadyDone); // copiedVersionFrom() must be called on the primary builder before // other builders. alreadyDone.put(alreadyDone, newBase); return copiedVersionFrom(alreadyDone); }
Expression expression = item.getAttributeExpression(); if ((expression != null) && (alreadyDone.get(expression.getBuilder()) != null)) { expression = expression.copiedVersionFrom(alreadyDone); Expression item = (Expression)groupByExpressions.elementAt(i); if (alreadyDone.get(item.getBuilder()) != null) { groupByExpressions.set(i, item.copiedVersionFrom(alreadyDone)); Expression item = (Expression)orderByExpressions.elementAt(i); if (alreadyDone.get(item.getBuilder()) != null) { orderByExpressions.set(i, item.copiedVersionFrom(alreadyDone));
/** * Rebuild the expressions with the correct expression builder if using a different one. * Exact copy of the another rebuildAndAddExpressions adopted to a Map with Expression values * as the first parameter (instead of Vector in the original method) */ public void rebuildAndAddExpressions(Map expressions, Vector allExpressions, ExpressionBuilder primaryBuilder, Dictionary clonedExpressions) { Iterator it = expressions.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry)it.next(); Object fieldOrExpression = entry.getValue(); if (fieldOrExpression instanceof Expression) { Expression expression = (Expression)fieldOrExpression; ExpressionBuilder originalBuilder = expression.getBuilder(); if (originalBuilder != primaryBuilder) { // For bug 2612185 avoid rebuildOn if possible as it rebuilds all on a single base. // i.e. Report query items could be from parallel expressions. if (clonedExpressions.get(originalBuilder) != null) { expression = expression.copiedVersionFrom(clonedExpressions); //if there is no builder or it is a copy of the base builder then rebuild otherwise it is a parallel expression not joined } if (originalBuilder.wasQueryClassSetInternally()) { // Possibly the expression was built with the wrong builder. expression = expression.rebuildOn(primaryBuilder); } entry.setValue(expression); } allExpressions.addElement(expression); } } }
/** * Rebuild the expressions with the correct expression builder if using a different one. */ public void rebuildAndAddExpressions(Vector expressions, Vector allExpressions, ExpressionBuilder primaryBuilder, Dictionary clonedExpressions) { for (int index = 0; index < expressions.size(); index++) { Object fieldOrExpression = expressions.elementAt(index); if (fieldOrExpression instanceof Expression) { Expression expression = (Expression)fieldOrExpression; ExpressionBuilder originalBuilder = expression.getBuilder(); if (originalBuilder != primaryBuilder) { // For bug 2612185 avoid rebuildOn if possible as it rebuilds all on a single base. // i.e. Report query items could be from parallel expressions. if (clonedExpressions.get(originalBuilder) != null) { expression = expression.copiedVersionFrom(clonedExpressions); //if there is no builder or it is a copy of the base builder then rebuild otherwise it is a parallel expression not joined } if (originalBuilder.wasQueryClassSetInternally()) { // Possibly the expression was built with the wrong builder. expression = expression.rebuildOn(primaryBuilder); } expressions.setElementAt(expression, index); } allExpressions.addElement(expression); } } }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); if (getFirstChild() != null) { setFirstChild(getFirstChild().copiedVersionFrom(alreadyDone)); } if (getSecondChild() != null) { setSecondChild(getSecondChild().copiedVersionFrom(alreadyDone)); } }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); if (getLocalBase() != null) { setLocalBase(getLocalBase().copiedVersionFrom(alreadyDone)); } if (getBaseExpression() != null) { setBaseExpression(getBaseExpression().copiedVersionFrom(alreadyDone)); } }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); clearAliases(); if (baseExpression != null) { baseExpression = baseExpression.copiedVersionFrom(alreadyDone); } derivedFields = copyCollection(derivedFields, alreadyDone); derivedTables = copyCollection(derivedTables, alreadyDone); }
/** * The query must be cloned, and the sub-expression must be cloned using the same outer expression identity. */ protected void postCopyIn(Dictionary alreadyDone) { super.postCopyIn(alreadyDone); setBaseExpression(getBaseExpression().copiedVersionFrom(alreadyDone)); ReportQuery clonedQuery = (ReportQuery)getSubQuery().clone(); if ((!clonedQuery.isCallQuery()) && (clonedQuery.getSelectionCriteria() != null)) { clonedQuery.setSelectionCriteria(getSubQuery().getSelectionCriteria().copiedVersionFrom(alreadyDone)); // If we are building/cloning a selection criteria for a batch query, a little extra work // needs to be done (see bug 2812185). if (alreadyDone.get(alreadyDone) != null) { clonedQuery.copyReportItems(alreadyDone); } } setSubQuery(clonedQuery); }
expression = expression.copiedVersionFrom(clonedExpressions); } else {
baseExp = (QueryKeyExpression)baseExp.copiedVersionFrom(clonedExpressions); } else { baseExp = (QueryKeyExpression)baseExp.rebuildOn(getExpressionBuilder());
expression = expression.copiedVersionFrom(clonedExpressions);