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:

<select id="employeeData" resultClass="map">
        SELECT *
          FROM dept, emp, bonus
         WHERE dept.deptno = emp.deptno AND emp.ename = 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 java bean to improve performance,
maybe like this:

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

<resultMap id="employeeResultMap" class="com.test.EmployeeData">
        ...
</resultMap>

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:

<resultMap id="employeeResultMap" class="com.test.ResultClass">
        <result property="dept.deptno" column="DEPTNO" javaType="string"
jdbcType="VARCHAR2"/>
        ...
        <result property="emp.empno" column="EMPNO" javaType="string"
jdbcType="VARCHAR2"/>
        ...
        <result property="bonus.comm" column="COMM" javaType="string"
jdbcType="VARCHAR2"/>
        ...
</resultMap>

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

Reply via email to