IFAIK, not directly since Torque is based on a table record object model and a union statement is not a physical "table". Generally for things like this, you can drop down a "layer" into the village package "primitives" and deal with it there. This is very similar to using native JDBC, but if done correctly, will still preserve the compile time "schema checking" and DB independent parts of Torque. E.g., using the Peer objects to define columns and criteria to define the SQL terms.
However, I'm not sure that village will support UNIONs. So, you might have to just use JDBC (and the Torque.getConnection methods) to do this. A possible alternative would be to create a view based on a common union query and create a Torque object for this view. Then you could use the standard Torque methods to get the subsets you wanted from the view. If you really get inspired, it should be possible to have a generic "Helper" class to create the union from a couple of criteria objects. Maybe using standard JDBC or maybe just doing two Village queries. Then convert these to a list Village Record objects and call the populateObjects method in the Peer class you want to have then look like. Of course, these would be read only objects since which table the record id information applied to would be unknown. Also, if you union is actually coming from two tables with the same field names, you could do the same thing as a union with two queries. E.g. List<BaseObject> r1 = Sales2007Peer.doSelect(c); List<BaseObject> r2 = Sales2008Peer.doSelect(c); r1.addAll(r2); Iterator<BaseObject> it = r1.iterator(); While (it.hasNext() ) { BaseObject rec = it.next(); Item = rec.getByName("ITEM"); Price = rec.getByName("PRICE"); .... } > -----Original Message----- > From: Michael Herbold [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 25, 2008 9:45 AM > To: Apache Torque Users List > Subject: Using Union > > Hi, > > is there a way to use union in torque? > I tried to search for an example, but i didn't found anything > helpful... > > I like to handle something like this: > > statement_1 > union ( > statement_2 > ) > > Thank you and greetings > Michael > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]