db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Dietz <jo...@purplebear.com>
Subject Re: Retrieving Joined Data
Date Wed, 02 Jul 2003 17:28:25 GMT
Okay, I thought I could get the joined data by calling something like 
ItemPeer.doSelectJoinCategory(), but the doSelectJoin methods appear to 
be defined as Protected, so I can't call them from my other packages, 
although this appears to be the documented way to do Joins and get the 
resulting data.

Given that, I don't see at all how to actually do a Join and get the 
resulting data.  The Torque documentation has several examples of 
creating the Join criteria without any examples of actually retrieving 
the data, and I haven't found any clear answer in the listserv archive 
either.

So my simple question is: How can you do a join of tables and get the 
full results?

Thanks,

John Dietz

On Monday, June 30, 2003, at 11:08  PM, John Dietz wrote:

> I'm having a hard time seeing the value if the Criteria addJoin method 
> given that it doesn't do quite what I expected.  Let me explain by 
> example:
>
> Let's say I have two tables, Category and Item, with a FK relationship 
> where each Category has several Items (reference to the Category it 
> Item).
> Here's what I was hoping for, if I do this:
> Criteria crit = new Criteria();
> crit.addJoin(CategoryPeer.CATEGORY_ID, ItemPeer.CATEGORY_ID);
> List categories = CategoryPeer.doSelect(crit);
>
> What I was hoping for was a List of all the Categories, prefilled with 
> the Items available using Category.getItems();
> What in fact happens is that the list of Categories includes duplicate 
> Categories, one for each item (like the resultset you would expect 
> from a straight SQL Join), then a call to Category.getItems() run's 
> another query to get all of the Items.
>
> I realize I could do a ItemPeer.doSelectJoinCategory(), which would 
> get me a list of all the Items with the Category prefilled, but I 
> would really like to get a list of Categories with the getItems() 
> prefilled (instead of running another query to get the list for each 
> Category).
>
> So if I don't get that with the addJoin(), then is there some other 
> way to get that result?
>
> John Dietz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


Mime
View raw message