You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by "Michael Wa (JIRA)" <ji...@apache.org> on 2014/07/30 09:45:38 UTC

[jira] [Created] (TORQUE-322) Support for SQL Set Operations (UNION, INTERSECT, ...)

Michael Wa created TORQUE-322:
---------------------------------

             Summary: Support for SQL Set Operations (UNION, INTERSECT, ...)
                 Key: TORQUE-322
                 URL: https://issues.apache.org/jira/browse/TORQUE-322
             Project: Torque
          Issue Type: New Feature
    Affects Versions: 4.0
            Reporter: Michael Wa


* It would be nice to support sql constructs like:
SELECT * FROM sales2005 UNION SELECT * FROM sales2006;

* If you want to realize the UNION operator you have to do something like that:

[...]
Criteria criteriaA = new Criteria();
criteriaA.where( ... );
criteriaA.addSelectColumn(COLUMNX);

Query queryA = SqlBuilder.buildQuery(criteriaA);
String sqlA = queryA.toString();
List<Object> replacementsA = queryA.getPreparedStatementReplacements();

Criteria criteriaB = new Criteria();
criteriaB.where( ... );
criteriaB.addSelectColumn(...);

Query queryB = SqlBuilder.buildQuery(criteriaB);
String sqlB = queryB.toString();
List<Object> replacementsB = queryB.getPreparedStatementReplacements();

List<Object> replacements = Lists.newArrayList();
replacements.addAll(replacementsA);
replacements.addAll(replacementsB);

String sql = COLUMNX + " IN (" + sqlA + " UNION " + sqlB + ")";

mainCriteria.whereVerbatimSql(sql, replacements.toArray());
[...] 





--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org