ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marnix Bindels <Marnix.Bind...@chess.nl>
Subject Property lookup at wrong level (Nested resultMap, groupBy)
Date Mon, 07 Nov 2005 15:19:16 GMT
Dear all,

I keep getting the iBatis error There is no READABLE property named 
'values' in class 'nl.chess.it.arvato.pathe.A'. Did I misunderstand the 
entire groupBy concept or what?

Here's my setup:
 MySql 4.1.7-nt, iBatis 2.1.5, Java 1.4

I am trying to get 3 levels of lists working: class A has a list of 
class B objects, and each B object has a list of Integers.
A single query gets the following from the database (a_id,b_id, value):

1, 1, 800
1, 1, 801
1, 1, 803
1, 2, 5
1, 2, 25
1, 2, 525

which I try to map using the following resultMaps:

<sqlMap namespace="Contract">
    <resultMap id="ValuesResult" class="java.lang.Integer">
        <result property="value" column="value" />
    <resultMap id="BResult" class="nl.chess.it.arvato.pathe.B" 
groupBy="ID" >
        <result property="ID" column="b_id" />
        <result property="values" resultMap="Contract.ValuesResult" />
    <resultMap id="AResult" class="nl.chess.it.arvato.pathe.A" 
groupBy="ID" >
        <result property="ID" column="a_id" />
        <result property="myBs" resultMap="Contract.BResult" />

on to a Single A object (ID=1) with a list of 2 B Objects ([B(ID=1, List 
[800,801,803]),B(ID=2, List[5,25,525])]

How do I correctly convince iBatis to look for the values property in 
class B instead of class A?

If any of you brave listeners want to join in :

    <statement id="CreateTA">
        create table T_A
            ID int not null,
            primary key (ID)
    <statement id="CreateTA">
        create table T_B
            ID int not null,
            A_ID int not null,
            mylist int,
            primary key (ID)
    <statement id="CreateWoop">
        create table woop
            listid int not null,
            value int not null,
    <select id="getA" parameterClass="contractKey" 
        select t_a.id a_id, t_b.id as b_id, value
         t_b join t_a on (t_a.id = t_b.a_id)
         join woop on (t_b.mylist = woop.listid)               
                <isNotEqual property="contractID" compareValue="-1">
                    t_a.id = #contractID#


Nieuwe Gracht 13
postbus 5021
2000 CA  Haarlem

+31 (0) 23 5149 135


View raw message