Thank you, that helped. So does this code

    Criteria c = new Criteria();
    c.addJoin(UserItemPeer.ITEM_ID,ItemPeer.ITEM_ID);
    c.add(UserItemPeer.USER_ID,user);
    doSelect...

result in that sql:

"SELECT item.* FROM item,user_item WHERE user_item.user_id=x AND
user_item.item_id=item.item_id"

?


> -----Urspr�ngliche Nachricht-----
> Von: Campbell, Justin [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 20. Januar 2003 19:54
> An: 'Turbine Torque Users List'
> Betreff: RE: torque-performance using cross-references
>
>
> Marc -
>
> You can definitely do this using Criteria without the need for a SQL
> statement execution for each item in your user loop.
>
> Check out the join section in the Torque Criteria Howto:
> http://jakarta.apache.org/turbine/torque/criteria-howto.html
>
> This is assuming you're familiar with SQL joins. If you're not,
> let us know
> :)
>
> Good luck,
> Justin
>
> -----Original Message-----
> From: Marc Lustig [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 20, 2003 1:38 PM
> To: Torque Users List
> Subject: torque-performance using cross-references
>
>
> Hi,
> I have a general question regarding performance.
> In my Torque-BO-model I have a lot of cross-references /foreign-keys.
> For instance:
>
> TABLE user_item
> user_id|item_id
>
> TABLE item
> item_id|itemattribute
>
> Now what I need to do is getting all item's that belong to user x.
>
> The SQL would look like this:
> "SELECT item.* FROM item,user_item WHERE user_item.user_id=x AND
> user_item.item_id=item.item_id"
>
>
> My current Java-code looke like this:
>
>     Criteria c = new Criteria();
>     c.add(UserItemPeer.USER_ID,user);
>     List list = UserItemPeer.doSelect(c);
>     List r = new ArrayList();
>     for (int i=0;i<list.size();i++) {
>       r.add(((UserItem)list.get(i)).getItem());
>     }
>
> As you see, this requires a single SQL-query for each entry in user_item.
> Question: is it possible to this using a single Torque-method that makes a
> single query the way I mentioned above?
>
> Or is the only way to drop a JDBC Statement?
>
> Thanks.
> Marc
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to