You can write your own method getAuthorJoinBooks( Criteria criteria ) that will execute the prefill of the books. The method executes only one SQL query.
You can look at the code torque generates for doSelectJoinAuthor and make some small changes (instead of one to one you will have a one to many so you will need a while... and so on). This worked for me. HIH, Alex > -----Original Message----- > From: Artur Z [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 02, 2004 11:43 AM > To: Apache Torque Users List > Subject: Re: doSelect with collections filled > > > > Did you defined the foreign key relationship beetwen Author and > > Book in your schema file? > > If yes, there should be protected method in BaseAuthorPeer > > doSelectJoinBooks() (or something like that). Write this method as > > public in AuthorPeer > > and than you can use it. > > > yes, I defined, but there is no such method > torque generated only method BaseBookPeer.doSelectJoinAuthor(...) > as far as I know torque generates only methods for accessing > associations > (one), but not collections > if you want to access a collection you call > author.getBooks(), and it reads > books from db, caches it and returns - it couses perfirmance > issues (one db > call for each getXXXs() method) > > how to solve it ? > how to query author table to get in return list of authors > with ALREADY > INITIALIZED books collections ? > > I found one solution in > http://www.mail-archive.com/[EMAIL PROTECTED]/msg01712.html > but is not handy and you operate on array of objects, not > getXXXs() methods > and collections > > > > ----- Original Message ----- > From: "Andras Balogh" <[EMAIL PROTECTED]> > To: "Apache Torque Users List" <[EMAIL PROTECTED]> > Sent: Thursday, September 02, 2004 10:25 AM > Subject: Re: doSelect with collections filled > > > > Hello, > > > > Did you defined the foreign key relationship beetwen Author and > > Book in your schema file? > > If yes, there should be protected method in BaseAuthorPeer > > doSelectJoinBooks() (or something like that). Write this method as > > public in AuthorPeer > > and than you can use it. > > Notice that the join made by Torque when selecting > authors and books > > is inner join > > so you won't have the authors who don't have at least a book. > > (can be changed i think to left outer join if you patch torque to > > support outer joins, see mail archive) > > > > Best regards, > > Andras. > > > > Artur Z wrote: > > > > >hello > > > > > >please help - I have a performance problem > > >there are two tables: Book and Author > > >I call AuthorPeer.doSelect(new Criteria()); - it returns > all authors > > >now i want to print all authors and their books > > >on each author I must call author.getBooks(); > > >every time I call this method a database is queried for > books for this > > >author > > >and when there are 2000 authors, there will be 2000 calls > to database, > which > > >of course takes much time > > > > > >the question is: > > >how to query author table to get in return list of authors > with already > > >initialized books collections > > > > > >thanks a lot > > > > > >Artur > > > > > > > > > > > > >--------------------------------------------------------------------- > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]