Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 1866 invoked from network); 19 Jan 2006 16:57:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Jan 2006 16:57:54 -0000 Received: (qmail 98488 invoked by uid 500); 19 Jan 2006 16:57:52 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 98474 invoked by uid 500); 19 Jan 2006 16:57:52 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 98459 invoked by uid 99); 19 Jan 2006 16:57:52 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2006 08:57:52 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.175.229.106] (HELO mail.seitenbau.net) (194.175.229.106) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2006 08:57:50 -0800 Received: from [192.168.15.18] (helo=www.seitenbau.net) by router1.seitenbau.net with esmtp (Exim 4.43) id 1Ezd6H-0005NY-He for torque-user@db.apache.org; Thu, 19 Jan 2006 17:57:29 +0100 In-Reply-To: Subject: RE: Joins in torque To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.5 September 26, 2003 Message-ID: From: Thomas Fischer Date: Thu, 19 Jan 2006 17:57:28 +0100 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 19.01.2006 05:57:29 PM MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, There is no built-in support at the moment to get more than one level o= f indrection read in at once. As far as I can see, you have 3 1/2 possibilities: 1a) read the values one after another. Assuming you have defined foreig= n keys (I'm not sure whether they should defined in T1 and T2 or in T12, = on this depends whether the doSelectJoinXXX methods are generated in T1Pee= r and T2Peer or in T12Peer), do T1Peer.doSelectJoinT12(). For each T1Entr= y you get, fetch the corresponding T12 Entry (this is already read from t= he database) and then do T12.getT2s() (this will access the database each = time you fetch a T2 Entry). 1b) do the same as in a1, but omit the T12.getT2s() step. Instead, get = all T2-Ids from all T12 you read in, do T2Peer.doSelect() with a criteria w= here all needed T2Ids are selected, and do the linking of the T2 objects to = the T12's manually. 2) look at the template code for generating the doSelectJoinXXX methods= and extend them for two levels of indirection. 3) A time ago, someone proposed a class which can read a whole tree of objects at once. It can be found in scarab (somewhere around TRQS260). = It is rather reflection-centric and I do not have an idea whether it works= with Torque 3.2, but maybe that is what you want. Personally, I use a modified method 1b). I would read all T1 I want, ga= ther the collection of T1 ids to read the associated T12's and link them manually to the T1's. Then I'd use the T2 ids from there to read the T2= 's, and link them manually to the T12's. This is rather fast (one select pe= r level of indirection, no object is transferred twice) and quite easy to= implement. You might have to override the initCollXXX() methods for the= used collections to make them public. Thomas "Stephan Spiegel" schrieb am 19.01.2006 17:17:29: > Hi, (in case this message is double please excuse me) > > I really do not understand what to do, I do not get the expected resu= lts! > > Let=B4s say I have 3 Tables: T1, T2 and T1_2 > T1: > ID (integer pk) > value (varchar) > ... > > T2: > ID (integer pk) > value (varchar) > ... > > T1_2: > T1_ID (integer fk->T1) > T2_ID (integer fk->T2) > > As a result, I would like to have a union table showing the values of= T1 and > T2 > in SQL this would be: select T1.value, T2.value from T1, T2, T1_2 whe= re > T1.ID =3D T1_2.T1_ID and T2.ID =3D T1_2.T2_ID > > if I get more than this (select * ...) would be fine as well. > > So, I have my classes but when I try to use them as written in Peers HowTo > (doSelectJoin...) or in Criteria HowTo (crit.addJoin(...)) I always g= et only > the values of the T1_2-table > > As a first step, I try just to get the first half (result should show= : > T1.value, T1_2.T2_ID) > so it should correspond to: > doSelectJoinT1(crit) in T1_2Peer > or: > crit.addJoin(T1.ID,T1_2.T1_ID,Criteria.LEFT_JOIN) > > as a result I just get the T1_2 values. I checked the mailing-list-archives, > I can=B4t find a helpful message. Where is my mistake? Could somebody= tell me > exactly how to add this join? > > (I=B4m using torque-3.2, MySQL 5, defaultidMethod=3Dnative) > > thanks in advance, Stephan > > > > ---------------------------------------------------------------------= > 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