/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
/** * Deep clone this object to produce a new identical query. * @return Deep clone */ public Object clone() { SetQuery copy = new SetQuery(this.operation); this.copyMetadataState(copy); copy.leftQuery = (QueryCommand)this.leftQuery.clone(); copy.rightQuery = (QueryCommand)this.rightQuery.clone(); copy.setAll(this.all); if(this.getOrderBy() != null) { copy.setOrderBy(this.getOrderBy().clone()); } if(this.getLimit() != null) { copy.setLimit( (Limit) this.getLimit().clone() ); } copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class)); if (this.projectedTypes != null) { copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes), this.metadata); } return copy; }
public static org.teiid.query.sql.lang.SetQuery helpExampleSetQuery() { org.teiid.query.sql.lang.SetQuery setQuery = new org.teiid.query.sql.lang.SetQuery(Operation.UNION); setQuery.setAll(false); setQuery.setLeftQuery(TestQueryImpl.helpExample(true)); setQuery.setRightQuery(TestQueryImpl.helpExample(true)); setQuery.setOrderBy(TestOrderByImpl.helpExample()); return setQuery; }
processOrderBy(sort, unionCommand, context); orderBy = unionCommand.getOrderBy(); unionCommand.setOrderBy(null); processLimit(limit, unionCommand, metadata); unionCommand.setOrderBy(orderBy); return unionCommand;
processOrderBy(sort, unionCommand, modelID, context, capFinder); orderBy = unionCommand.getOrderBy(); unionCommand.setOrderBy(null); processLimit(limit, unionCommand, metadata); unionCommand.setOrderBy(orderBy); return unionCommand;
processOrderBy(sort, unionCommand, context); orderBy = unionCommand.getOrderBy(); unionCommand.setOrderBy(null); processLimit(limit, unionCommand, metadata); unionCommand.setOrderBy(orderBy); return unionCommand;
@Test public void testSetQuery3() { 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); Select s2 = new Select(); s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$ From f2 = new From(); f2.addGroup(new GroupSymbol("m.g2")); //$NON-NLS-1$ Query q2 = new Query(); q2.setSelect(s2); q2.setFrom(f2); OrderBy orderBy = new OrderBy(); orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$ SetQuery sq = new SetQuery(Operation.UNION, false, q1, q2); sq.setOrderBy(orderBy); helpTest(sq, "SELECT e1 FROM m.g1 UNION SELECT e1 FROM m.g2 ORDER BY e1"); //$NON-NLS-1$ }
/** SELECT x FROM g INTERSECT SELECT y FROM h ORDER BY x */ public static final SetQuery sample2() { Query q1 = new Query(); Select select = new Select(); select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$ q1.setSelect(select); From from = new From(); from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$ q1.setFrom(from); Query q2 = new Query(); select = new Select(); select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$ q2.setSelect(select); from = new From(); from.addGroup(new GroupSymbol("h")); //$NON-NLS-1$ q2.setFrom(from); SetQuery sq = new SetQuery(Operation.INTERSECT); sq.setAll(false); sq.setLeftQuery(q1); sq.setRightQuery(q2); OrderBy orderBy = new OrderBy(); orderBy.addVariable(new ElementSymbol("x")); //$NON-NLS-1$ sq.setOrderBy(orderBy); return sq; }