Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 90040 invoked from network); 20 Jan 2006 23:15:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jan 2006 23:15:06 -0000 Received: (qmail 21460 invoked by uid 500); 20 Jan 2006 23:14:39 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 20135 invoked by uid 500); 20 Jan 2006 23:14:30 -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 20027 invoked by uid 99); 20 Jan 2006 23:14:28 -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 15:14:28 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.82.206 as permitted sender) Received: from [66.249.82.206] (HELO xproxy.gmail.com) (66.249.82.206) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jan 2006 15:10:38 -0800 Received: by xproxy.gmail.com with SMTP id s19so360570wxc for ; Fri, 20 Jan 2006 15:10:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=RdXqjbjcEekjJm0wkcqi1Fq1zuNTubgqRVR3zh7ylaLQW83NSrKuPFU4qa/6jSVatrWRATO4M22I9SjlD901sv0Dbtj6BhNem12xeFST4B9Sam/prcjPv7nf8CMlmSBNr+VYz4vUi5VhmwOrg2e/N6U14O5AAVlBvlorwE6bqF8= Received: by 10.70.60.18 with SMTP id i18mr2720973wxa; Fri, 20 Jan 2006 15:10:17 -0800 (PST) Received: by 10.70.72.11 with HTTP; Fri, 20 Jan 2006 15:10:17 -0800 (PST) Message-ID: Date: Fri, 20 Jan 2006 17:10:17 -0600 From: Jeff Butler To: user-java@ibatis.apache.org Subject: Re: iBatis usage pattern In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14772_22800222.1137798617925" References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_14772_22800222.1137798617925 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Yusuf, This is a big question! Clinton is right that a JavaBean will be faster, but I've always thought that the performance gain will be negligible and not noticed by any user. For me, this is not enough of an argument one way or the other. I have been on both sides of the issue with Maps. I like maps because I don't have to create a POJO for every query. But also like the more robust datatype mapping that is available if you make a POJO. And you can use iBATIS "group by" functionality with a POJO and fill out a big object graph if you need to. For me the bottom line is that you should create a good POJO based domain model for your application, and then map as many of those classes to iBATIS methods as possible. If you need to add an occaisional Map here and there for a wierd one-of-a-kind query, then I'd do it rather than messing up the domain model. So the domain model is most imprtant to me. My thoughts... Jeff Butler On 1/19/06, Yusuf wrote: > > Hello, > I've been using ibatis for quite some time now, and I like to ask some > questions to all ibatis gurus out there... > - For queries with joins from many table, i usually map results to a Map > (no need to make custom beans), for example: > > > > But in the wiki about improving sqlmaps performance > (http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do+I > +improve+SQL+Map+performance), > Mr. Clinton said that always use a java bean to improve performance, > maybe like this: > > > > > ... > > > But how if we have so many multiple table queries, should I just make a > bean class for each custom queries i made (there are many of them)? Or > should I make a bean for each table in the database, for example maybe > we have classes Employee, Dept, Bonus, and define the resultMap like > this: > > > jdbcType=3D"VARCHAR2"/> > ... > jdbcType=3D"VARCHAR2"/> > ... > jdbcType=3D"VARCHAR2"/> > ... > > > and the ResultClass: > > class ResultClass{ > private Dept dept; > private Emp emp; > private Bonus bonus; > > //... getter setter > } > > Thank you, and I'm sorry for a rather long question, but I've been > wondering about how do people used to map their results. > > Yusuf > > ------=_Part_14772_22800222.1137798617925 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi Yusuf,
 
This is a big question!
 
Clinton is right that a JavaBean will be faster, but I've always thoug= ht that the performance gain will be negligible and not noticed by any user= .  For me, this is not enough of an argument one way or the other.
 
I have been on both sides of the issue with Maps.  I like ma= ps because I don't have to create a POJO for every query.  But also li= ke the more robust datatype mapping that is available if you make a POJO.&n= bsp; And you can use iBATIS "group by" functionality with a POJO = and fill out a big object graph if you need to.
 
For me the bottom line is that you should create a good POJO based dom= ain model for your application, and then map as many of those classes to iB= ATIS methods as possible.  If you need to add an occaisional Map here = and there for a wierd one-of-a-kind query, then I'd do it rather than messi= ng up the domain model.
 
So the domain model is most imprtant to me.
 
My thoughts...
 
Jeff Butler
 

 
On 1/19/06, = Yusuf <Yusuf@ekalife.co.id> wrote:
Hello,
I've been using ibatis= for quite some time now, and I like to ask some
questions to all ibatis= gurus out there...
- For queries with joins from many table, i usually map results to a Ma= p
(no need to make custom beans), for example:

<select id=3D&q= uot;employeeData" resultClass=3D"map">
  &nb= sp;    SELECT *
         FROM dept, emp, bonus<= br>        WHERE dept.deptno =3D em= p.deptno AND emp.ename =3D bonus.ename(+)
</select>

But in = the wiki about improving sqlmaps performance
(
http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do+I=
+improve+SQL+Map+performance),
Mr. Clinton said that always use a ja= va bean to improve performance,
maybe like this:

<select id=3D= "employeeData" resultMap=3D"employeeResultMap">
       SELECT *
   &nbs= p;     FROM dept, emp, bonus
    = ;    WHERE dept.deptno =3D emp.deptno AND emp.ename =3D= bonus.ename(+)
</select>

<resultMap id=3D"employee= ResultMap" class=3D"com.test.EmployeeData ">
       ...
</resultMap>= ;

But how if we have so many multiple table queries, should I just m= ake a
bean class for each custom queries i made (there are many of them)= ? Or
should I make a bean for each table in the database, for example ma= ybe
we have classes Employee, Dept, Bonus, and define the resultMap likethis:

<resultMap id=3D"employeeResultMap" class=3D&quo= t;com.test.ResultClass">
       &l= t;result property=3D"dept.deptno " column=3D"DEPTNO" javaType=3D"string"
jdbcTyp= e=3D"VARCHAR2"/>
       ...       <result property=3D"emp.empn= o" column=3D"EMPNO" javaType=3D"string"
jdbcType=3D"VARCHAR2"/>
      = ; ...
       <result property=3D"b= onus.comm" column=3D"COMM" javaType=3D"string"
= jdbcType=3D"VARCHAR2"/>
      = ; ...
</resultMap>

and the ResultClass:

class ResultClass{
   = ;    private Dept dept;
     &nb= sp; private Emp emp;
       private Bonus = bonus;

       //... getter setter
}=

Thank you, and I'm sorry for a rather long question, but I've been
wondering about how do people used to map their results.

Yusuf

------=_Part_14772_22800222.1137798617925--