db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Lustig" <m...@marclustig.com>
Subject torque-performance using cross-references
Date Mon, 20 Jan 2003 18:38:24 GMT
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


Mime
View raw message