Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 52913 invoked from network); 20 Jan 2006 22:12:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jan 2006 22:12:06 -0000 Received: (qmail 16332 invoked by uid 500); 20 Jan 2006 22:12:05 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 15993 invoked by uid 500); 20 Jan 2006 22:12:04 -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 15982 invoked by uid 99); 20 Jan 2006 22:12:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jan 2006 14:12:03 -0800 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=RCVD_NUMERIC_HELO X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.87.138.105] (HELO metaframe.rent-a-brain.de) (212.87.138.105) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 20 Jan 2006 14:12:02 -0800 Received: from 212.87.138.97 ([212.87.138.97]) by ipcase (JAMES SMTP Server 2.2.0) with SMTP ID 374 for ; Fri, 20 Jan 2006 23:34:32 +0100 (CET) Received: from ipcase (ipcase.rent-a-brain.de [212.87.138.125]) by mailer.rent-a-brain.de (8.11.0/8.10.2/SuSE Linux 8.10.0-0.3) with SMTP id k0KMBcW14216 for ; Fri, 20 Jan 2006 23:11:38 +0100 Received: from 212.87.138.97 ([212.87.138.97]) by ipcase (JAMES SMTP Server 2.2.0) with SMTP ID 979 for ; Fri, 20 Jan 2006 23:34:31 +0100 (CET) Received: from SERVER (p5080B2BA.dip0.t-ipconnect.de [80.128.178.186]) by mailer.rent-a-brain.de (8.11.0/8.10.2/SuSE Linux 8.10.0-0.3) with SMTP id k0KMBbW14203 for ; Fri, 20 Jan 2006 23:11:37 +0100 From: "Stephan Spiegel" To: "Apache Torque Users List" Subject: AW: Joins in torque Date: Fri, 20 Jan 2006 23:12:18 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal In-Reply-To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, first thanks for the fast and good response. The doSelectJoinXXX methods are in the BaseT12Peer because here are the foreign keys pointing to T1 and T2, so I could/can do T12.doSelectJoinT1() and T12.doSelectJoinT2(). The point is, that I do not get any other result then just doing a doSelect and manually bring them together as done in the following example: (Method in T12Peer): public static List bringThemTogether () throws TorqueException { Criteria crit = new Criteria(); List xx = doSelect(crit); for (int i = 0; i < xx.size(); i++) { T12 temp_obj1 = (T12)xx.get(i); T1 temp_obj2 = (T1)temp_obj1.getT1(); T2 temp_obj3 = (T2)temp_obj1.getT2(); HashMap h = new HashMap(); h.put("Table1",temp_obj2); h.put("Table2",temp_obj3);} xx.set(i,h); } return xx; } using this I can directly access the relations between the values of T1 and T2. I can't really see an effect using the doSelectJoin methods, but may be I'm totally blind in the moment. Or does the above method hundreds of selects? (I will have a look for the log4j as mentioned of Greg) Stephan -----Urspr�ngliche Nachricht----- Von: Thomas Fischer [mailto:fischer@seitenbau.net] Gesendet: Donnerstag, 19. Januar 2006 17:57 An: Apache Torque Users List Betreff: RE: Joins in torque Hi, There is no built-in support at the moment to get more than one level of 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 foreign 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 T1Peer and T2Peer or in T12Peer), do T1Peer.doSelectJoinT12(). For each T1Entry you get, fetch the corresponding T12 Entry (this is already read from the 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 where 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, gather 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 per 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 results! > > Let�s 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 where > T1.ID = T1_2.T1_ID and T2.ID = 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 get 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�t find a helpful message. Where is my mistake? Could somebody tell me > exactly how to add this join? > > (I�m using torque-3.2, MySQL 5, defaultidMethod=native) > > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org