ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Vondrak <i...@centrum.cz>
Subject Re: performance issue for id as association
Date Sun, 21 Feb 2010 11:15:57 GMT
Guy Rouillier wrote:
> On 2/20/2010 3:21 PM, Jakub Vondrak wrote:
>> Hello,
>>
>> I'm new to iBatis 3 so maybe I'm overooking something obvious, but I'm
>> having problem while trying to map id object as association.
>>
>> Here is my result map
>>
>>     <resultMap id="billResultMap" type="Bill">
>>        <id column="bill_id" property="id" />
>>        <collection property="billItems" ofType="BillItem">
>>            <result column="bi_sku" property="customId" />
>>            <result column="bi_name" property="name" />
>>            ...
>>
>>           <association property="id" javaType="BillItemId">
>>              <id column="bill_id" property="idBill"/>
>>              <id column="bill_id" property="itemOrder" />
>>           </association>
>>        </collection>
>>     </resultMap>
>>
>> Problem is that class BillItem has another class BillItemId which acts
>> as ID, but I'm not able to express this fact in result map.
>> This is probably the reason why I'm having performance problems
>> (java.lang.OutOfMemoryError: Java heap space).
>>
> 
> That's not a performance problem, that's an out-of-memory problem.  You
> probably have a circular reference.  Take a look in the User Guide PDF
> in the section titled Advanced Result Mapping.  It has an example using
> an association.  An association is a 1-to-1 mapping.  Your example above
> doesn't identify a column on which to establish the association.  It
> also lists two <id> entries, both for the same source column.  That
> can't be right.
> 
Thanks for the answer. If I reduce returned record count, I don't get
OutOfMemory, but I'm still not able to do what I need in mapping and I
guess that OutOfMemory exception is related to it.

First let me give you more information:

DB schema looks like this:

CREATE TABLE BILL(
    ID INTEGER NOT NULL PRIMARY KEY
)

CREATE TABLE BILL_ITEM(
    ID_BILL INTEGER NOT NULL,
    ITEM_ORDER INTEGER NOT NULL,
    SKU VARCHAR(255),
    NAME VARCHAR(255),
    PRIMARY KEY(ID_BILL,ITEM_ORDER),
    CONSTRAINT BILL FOREIGN KEY(ID_BILL) REFERENCES BILL(ID)
)

Mapping for select looks like this:
   <select id="selectAll" resultMap="billResultMap">
      select
      B.id as bill_id,
      BI.item_order as bi_item_order,
      BI.sku as bi_sku,
      BI.name as bi_name,
      from bill B
      left outer join bill_item BI on B.id = BI.id_bill
   </select>

What I guess is the problem is that I cannot express *composite key as
an BillItemId object* on the BillItem class and I guess I will need own
TypeHandler for whole Bill class.

I was expecting, that something like:
<id property="id" column="{idBill=bill_id, itemOrder=bi_item_order}"
javaType="BillItemId"/>
is possible, but it doesn't seem so.

Every combination I have tried yields following errors:
1) there is just one BillItem for each Bill
2) BillItemId for every BillItem is null

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message