Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 8578 invoked from network); 20 Sep 2005 12:37:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2005 12:37:15 -0000 Received: (qmail 16911 invoked by uid 500); 20 Sep 2005 12:37:13 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 16785 invoked by uid 500); 20 Sep 2005 12:37:12 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 16772 invoked by uid 99); 20 Sep 2005 12:37:12 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2005 05:37:12 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [213.138.34.28] (HELO bean.sungard.de) (213.138.34.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2005 05:37:21 -0700 Received: from ffm-iproxy.sungard.de (localhost [127.0.0.1]) by bean.sungard.de (8.12.3/8.12.3/SuSE Linux 0.6) with ESMTP id j8KCaw8C027102 for ; Tue, 20 Sep 2005 14:36:58 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Avoiding selects and other problems with complex objects / Hibernate Date: Tue, 20 Sep 2005 14:36:57 +0200 Message-ID: <6DB5565517FFA44498EA068EA7D23B33077DDC@ffm-mx2.banking.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Avoiding selects and other problems with complex objects / Hibernate Thread-Index: AcW90D3jp8nhRuD3Qy+nS01m69wNGAAC5phg From: "Farsi, Reza" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, I don't know, if I can describe my queotion clealy, but I try it. Following scenario: There are two objects Fund and Instrument. Instrument hat one composite object called Interest. Fund does not reference any other obejct. Instrument reference only Interest. There is also an obejct called BookingRequest that references a Fund and an Instrument. Database modeling is as followes create table fund ( id int not null auto_increment primary key,=20 name varchar(50) not null, ... ); create table instrument ( id int not null auto_increment primary key,=20 name varchar(12) not null unique, ... );=20 create table interest ( instrument_id int not null auto_increment primary key, name varchar(12) not null, ...,=20 constraint interest_fk_01 foreign key (instrument_id) references instrument (id) ON DELETE CASCADE ON UPDATE CASCADE );=20 create table booking_request ( id int not null auto_increment primary key,=20 fund_id int not null,=20 instrument_id int not null,=20 transaction_date date,=20 ..., constraint booking_request_fk_01 foreign key (fund_id) references dd_fondsstamm (id),=20 constraint booking_request_fk_02 foreign key (instrument_id) references ip_ins_instrument (id) ); And on the Java sind: public class Instrument { // parameters skipped private Interest interest; //.... // Getters and setters } public class BookingRequest { // parameters skipped private Fund fund; private Instrument instrument; //.... // Getters and setters } Fund and instrument have their own mapping files. By selecting instrument objects the problem of N+1-select is solved. Now assume that there is an BookingRequest DAO that supports a method "getBookingRequestByFund(int fundId)". By definition of mapping for BookingRequest the mapping of Fund and Instrument attributes are fetched using Select statements specified in Fund.xml respectivly Instrument.xml. That means, that fetching a BookingRequest causes three select calls. How can I get BookingRequest objects by only one select. A solution like mapping of referenced Fund within resultMap of the BookingRequest makes the mapping complex and the maintainace more difficult. I know that Hibernate takes care of the object relations and optimizes the select. Is there any mechanism in iBATIS provide this problem domain? Thanks in advance and frindly regards, Reza