You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Elie Medeiros <nc...@networkphotographers.com> on 2003/06/25 10:46:56 UTC

self joins in Torque

(sorry for double-post, got wrong subject in previous email)

hi there,

I've been looking to do a query with several self-joins in Torque and
haven't found much about how to do it, other than it is possible
according to the doc, and that the person who wrote that bit of the doc
has some "very efficient code" to do so (but doesn't mention what that
code is - point 4 in the intro to
http://db.apache.org/torque/peers-howto.html).

The query in SQL would look something like so:

SELECT sr1.key, sr2.key, sr3.key from results as sr1
INNER JOIN results AS sr2 ON sr2.key=sr1.key
INNER JOIN results as sr3 ON sr3.key=sr2.key
WHERE sr1.result_set='001'
AND sr2.result_set= '015'
AND sr3.result_set='098'

where the table definition looks something like:
------------------------------
|id   | key   | result_set   |
------------------------------

the idea is to get a set of keys which are contained in several
result_sets at a time.

I tried using Criterions as follows:
---
Criteria crit = new Criteria();
Criteria.Criterion tg1 = crit.getNewCriterion(ResultsPeer.RESULT_SET,
'001', Criteria.EQUAL);
Criteria.Criterion tg2 = crit.getNewCriterion(ResultsPeer.RESULT_SET,
'015', Criteria.EQUAL);
Criteria.Criterion tg3 = crit.getNewCriterion(ResultsPeer.RESULT_SET,
'098', Criteria.EQUAL);
crit.add(tg1.and(tg2.and(tg3)));
---

this doesn't work obviously - I'm not using joins. At the moment I use
OR as in (tg1.or(tg2.or(tg3))) and loop through the results in Java,
this is quite inefficient and a little ugly though. How would I add
joins to the Criteria and tell tg1 to relate to join1, tg2 to relate to
join 2 etc...? Any help greatly appreciated....

Nick

ps. if the person who wrote that post in the doc is still on the mailing
list, I for one am rather interested in his code to load a tree from the
db in a single hit :D

Re: Torque Presentation

Posted by Keshava Murthy <ke...@bigtec.org>.
Hi Hugh,
Can you send me the presentation slides with speaker notes? or an url for
download if the size is big.  I am from Bangalore, India.
regards,
Keshava Murthy. S

----- Original Message -----
From: "Hugh Brien" <hp...@comcast.net>
To: "Turbine Torque Users List" <to...@db.apache.org>
Sent: Wednesday, June 25, 2003 7:32 PM
Subject: Torque Presentation


> Just an FYI. I gave a presentation on Torque at our Northern Virginia Java
> User Group meeting last night. I had an audience of about 20.  It went
well
> and there were lots of question.  I think I may have encouraged several to
> take a closer look.  Also if there are any Torque users in the Mid
Atlantic
> region in the U.S. let me know.  I could do the presentation at your JUG
> also.
>
> r,
> Hugh
>
>
> Hugh P. Brien
> Vice President
> Dunbar Consulting, Inc.
> 703.725.7754
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>


Torque Presentation

Posted by Hugh Brien <hp...@comcast.net>.
Just an FYI. I gave a presentation on Torque at our Northern Virginia Java
User Group meeting last night. I had an audience of about 20.  It went well
and there were lots of question.  I think I may have encouraged several to
take a closer look.  Also if there are any Torque users in the Mid Atlantic
region in the U.S. let me know.  I could do the presentation at your JUG
also.

r,
Hugh


Hugh P. Brien
Vice President
Dunbar Consulting, Inc.
703.725.7754