ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Bidirectional association in iBATIS 3?
Date Fri, 04 Sep 2009 20:05:53 GMT
A stack overflow is most likely a bug in iBATIS.  Can you create a simple
unit test (HSQLDB or Derby/JavaDB) and create a Jira ticket for it?

I believe we have unit tests to cover this case, but your code must test the
framework in a new way.

Thanks much.

Clinton

On Fri, Sep 4, 2009 at 12:43 PM, rtrip <rtrip@mailinator.com> wrote:

>
> This may have been asked a couple of times, but I haven't seen a useful
> answer yet. My domain model has a parent-child relationship, but the child
> also needs to have a reference to the parent object. Something like
>
> Group {
>     int groupId;
>     String groupName;
>     List<Item> items;
>     .....
>     .....
> }
>
> Item {
>    int itemId;
>    String itemName;
>    Group parentGroup;
>    ....;
> }
>
>
> How do I express this relationship in a resultMap? I tried the following,
> but it gives me a StackOverflowError when I try to run a <select> query
> with
> a join between the Group and Item tables:
>
>    <resultMap id="groupMap" type="GroupDTO">
>        <id property="groupId" column="groupId"/>
>        <collection property="items" resultMap="itemMap"/>
>    </resultMap>
>
>    <resultMap id="itemMap" type="ItemDTO">
>            <id property="itemId" column="itemId"/>
>            <result property="objectId" column="objectId"/>
>            <result property="objectType" column="objectType"/>
>            <association property="parentGroup" column="groupId"
> resultMap="groupMap"/>
>    </resultMap>
>
> I'm sure I'm doing something wrong here with the circular reference, but I
> don't know what's the right way to do this. I have seen statements on this
> list referring to this issue being solved by the iBATIS cache, but I'm not
> sure how. Can anyone help, or point me to the solution? (Hibernate does
> this
> kind of stuff easily, but sucks for many other reasons)
>
> Thanks
>
> - rtrip
> --
> View this message in context:
> http://www.nabble.com/Bidirectional-association-in-iBATIS-3--tp25299690p25299690.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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