public static SubquerySetCriteria helpExample() { ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$ Query query = TestQueryImpl.helpExample(true); SubquerySetCriteria ssc = new SubquerySetCriteria(element, query); ssc.setNegated(true); return ssc; }
public void testEquals3() { SubquerySetCriteria c1 = example1(); SubquerySetCriteria c2 = c1.clone(); c2.setNegated(true); assertFalse("Set criteria are not the same", c1.equals(c2)); //$NON-NLS-1$ }
/** * Deep copy of object. The values Iterator of this object * will not be cloned - it will be null in the new object * (see #setValueIterator setValueIterator}). * @return Deep copy of object */ public SubquerySetCriteria clone() { Expression copy = null; if(getExpression() != null) { copy = (Expression) getExpression().clone(); } QueryCommand copyCommand = null; if(getCommand() != null) { copyCommand = (QueryCommand) getCommand().clone(); } SubquerySetCriteria criteriaCopy = new SubquerySetCriteria(copy, copyCommand); criteriaCopy.setNegated(isNegated()); criteriaCopy.subqueryHint = this.subqueryHint.clone(); return criteriaCopy; }
/** * Deep copy of object. The values Iterator of this object * will not be cloned - it will be null in the new object * (see #setValueIterator setValueIterator}). * @return Deep copy of object */ public SubquerySetCriteria clone() { Expression copy = null; if(getExpression() != null) { copy = (Expression) getExpression().clone(); } QueryCommand copyCommand = null; if(getCommand() != null) { copyCommand = (QueryCommand) getCommand().clone(); } SubquerySetCriteria criteriaCopy = new SubquerySetCriteria(copy, copyCommand); criteriaCopy.setNegated(isNegated()); criteriaCopy.subqueryHint = this.subqueryHint.clone(); return criteriaCopy; }
/** * Deep copy of object. The values Iterator of this object * will not be cloned - it will be null in the new object * (see #setValueIterator setValueIterator}). * @return Deep copy of object */ public SubquerySetCriteria clone() { Expression copy = null; if(getExpression() != null) { copy = (Expression) getExpression().clone(); } QueryCommand copyCommand = null; if(getCommand() != null) { copyCommand = (QueryCommand) getCommand().clone(); } SubquerySetCriteria criteriaCopy = new SubquerySetCriteria(copy, copyCommand); criteriaCopy.setNegated(isNegated()); criteriaCopy.subqueryHint = this.subqueryHint.clone(); return criteriaCopy; }
@Test public void testSubquerySetCriteria1() { GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); Select select = new Select(); select.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$ Expression expr = new ElementSymbol("b"); //$NON-NLS-1$ Criteria criteria = new CompareCriteria(new ElementSymbol("a2"), CompareCriteria.EQ, //$NON-NLS-1$ new Constant(new Integer(5))); Query query = new Query(); query.setSelect(select); query.setFrom(from); query.setCriteria(criteria); SubquerySetCriteria subCrit = new SubquerySetCriteria(expr, query); subCrit.setNegated(true); Query outer = new Query(); outer.setSelect(select); outer.setFrom(from); outer.setCriteria(subCrit); helpTest("SELECT a FROM db.g WHERE b NOT IN (SELECT a FROM db.g WHERE a2 = 5)", //$NON-NLS-1$ "SELECT a FROM db.g WHERE b NOT IN (SELECT a FROM db.g WHERE a2 = 5)", //$NON-NLS-1$ outer); }
@Test public void testSubquerySetCriteria2() { Select s1 = new Select(); s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$ From f1 = new From(); f1.addGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$ Query q1 = new Query(); q1.setSelect(s1); q1.setFrom(f1); ElementSymbol expr = new ElementSymbol("e2"); //$NON-NLS-1$ SubquerySetCriteria ssc = new SubquerySetCriteria(expr, q1); ssc.setNegated(true); helpTest(ssc, "e2 NOT IN (SELECT e1 FROM m.g1)"); //$NON-NLS-1$ }
|| (criteria.getOperator() == CompareCriteria.NE && criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL)) { SubquerySetCriteria result = new SubquerySetCriteria(criteria.getLeftExpression(), criteria.getCommand()); result.setNegated(criteria.getOperator() == CompareCriteria.NE); return rewriteCriteria(result);
|| (criteria.getOperator() == CompareCriteria.NE && criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL)) { SubquerySetCriteria result = new SubquerySetCriteria(criteria.getLeftExpression(), criteria.getCommand()); result.setNegated(criteria.getOperator() == CompareCriteria.NE); return rewriteCriteria(result);
|| (criteria.getOperator() == CompareCriteria.NE && criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL)) { SubquerySetCriteria result = new SubquerySetCriteria(criteria.getLeftExpression(), criteria.getCommand()); result.setNegated(criteria.getOperator() == CompareCriteria.NE); return rewriteCriteria(result);