db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dovlecel Alexandru Ovidiu <alexandru.dovle...@siemens.com>
Subject RE: JOIN & result
Date Thu, 29 Jul 2004 13:47:53 GMT
Hi, 

The Criteria is used in this way in order to make more complex queries that
involve several tables. The TableAPeer.doSelect( ) returns, as Siegfried
said, a list of TableA elements. THEY ARE NOT PREFILLED with their books. 

For example, you can execute a query to find all the authors for a book that
has the title "XYZ" like this: 

Criteria c = new Criteria() ;
crit.addJoin(TableAPeer.AUTHOR_ID, TableBPeer.AUTHOR_ID); 
crit.add( TableBPeer.BOOK_TITLE, "XYZ" ) ;
List items = TableAPeer.doSelect(crit);

By executing this code you will get the authors that wrote a book called
"XYZ", but you will not receive the books!!! 

In order to receive the authors prefilled with the books, you have to
implement your own method TableAPeer.doSelectJoinBooks() and... check some
methods that have the same behaviour and are already generated. 

HIH, 
Alex 


> -----Original Message-----
> From: "Göschl,Siegfried" [mailto:Siegfried.Goeschl@drei.com]
> Sent: Thursday, July 29, 2004 3:33 PM
> To: Apache Torque Users List
> Subject: RE: JOIN & result
> 
> 
> Hi Rie,
> 
> A Criteria is evaluated to return a list of records for an 
> existing table (as long as your working with Torque objects 
> and not Village records), i.e you don't work with a joined table:
> 
> List of XXX = XXXPeer.doSelect(criteria);
> 
> Cheers,
> 
> Siegfried Goeschl
> 
> -----Original Message-----
> From: Rie Nakajima [mailto:rienakajima092@hotmail.com] 
> Sent: Donnerstag, 29. Juli 2004 14:37
> To: torque-user@db.apache.org
> Subject: JOIN & result
> 
> 
> Hello.
> 
> Though it is so easy question, but please help me out to 
> complete my coding 
> using Torque for the first time. (I'm using Version 3.1)
> 
> I am writing code in order to execute JOIN SQL statement with torque.
> 
> Here is the sample tables.
> TableA has AUTHOR_ID, and AUTHOR_NAME.
> TableB has AUTHOR_ID, BOOK_TITLE, and ISBN.
> 
> In order to make JOIN statement, I would write as follows;
> 
> Criteria crit = new Criteria(); 
> crit.addJoin(TableAPeer.AUTHOR_ID, TableBPeer.AUTHOR_ID); 
> List items = TableAPeer.doSelect(crit);
> 
> Here is my question;
> After doing "doSelect" method, I would get item list which is 
> filled with 
> the all data from TableA and TableB.
> How can I get data for each column, such as data of 
> AUTHOR_NAME in TableA? (do I write like this?: 
> item.getAUTHOR_NAME();???)
> 
> Basically I couldn't figure out how the selected values are 
> stored in list 
> object when using JOIN.
> 
> Again, I know it might be too easy to post this mailing list, 
> but I will 
> appreciate if any of you would kindly answer this question..
> 
> Thank you in advance.
> 
> _________________________________________________________________
> Planning a family vacation? Check out the MSN Family Travel guide! 
> http://dollar.msn.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 

---------------------------------------------------------------------
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