You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by RO86 <ra...@yahoo.com> on 2009/05/11 14:52:42 UTC

HELP NEEDED : Bidirectional associations

Hi, All
Suppose this sitiuation
DB Tables:
                  A(ida, desc)              ,                 B(idb, ida,
desc)

Java Classes: 
public class A{ String ida; String desc; List Bs; }

public class B{String idb; String desc; A parentA;}

I am new to iBatis and I am trying to work around this problem. But I
couldn't find any examples , please any one can help me in this

THANKS
-- 
View this message in context: http://www.nabble.com/HELP-NEEDED-%3A-Bidirectional-associations-tp23482686p23482686.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: HELP NEEDED : Bidirectional associations

Posted by RO86 <ra...@yahoo.com>.
Hi Clinton,
First , Thanks for your reply.
I have enabled both cacheModelsEnabled and statementCachingEnabled, And I
created the maps as following:
<resultMap class="A" id="AResult" groupBy="ida">
	<result property="ida" column="ida" />
	<result property="desc" column="desc" />
	<result property="Bs" resultMap="BResult" />
</resultMap>

<resultMap class="B" id="BResult">
	<result property="idb" column="idb" />
	<result property="desc" column="desc" />
	<result property="parentA" resultMap="AResult" />
</resultMap>

And a select

<select id="getA" resultMap="AResult">
	SELECT
	A.ida as ida, 
	A.desc as desc,
	B.idb as idb,
	B.desc as bdesc, 	
	FROM A A, B B
	WHERE
	A.ida = B.ida
	and A.ida = #value#
</select>

And I get the following error when i call this select statment:
java.lang.StackOverflowError
	at sun.nio.cs.UTF_8$Decoder.decodeArrayLoop(UTF_8.java:270)
	at sun.nio.cs.UTF_8$Decoder.decodeLoop(UTF_8.java:416)
	at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:544)
	at java.lang.StringCoding$CharsetSD.decode(StringCoding.java:190)
	at java.lang.StringCoding.decode(StringCoding.java:228)
	at java.lang.String.<init>(String.java:405)
	.
	.
	.

Which is expected beacuse AResult will call BResult and BResult will call
AResult
So, How to solve this problem

Thanks

Clinton Begin wrote:
> 
> Currently, the trick is to ensure that you have caching enabled for those
> statements (caching of any configuration, other than weak reference
> caching,
> will work).
> This is not ideal and is solved by iBATIS 3.0, which is just around the
> corner.
> 
> Clinton
> 
> On Mon, May 11, 2009 at 6:54 AM, RO86 <ra...@yahoo.com> wrote:
> 
>> Hi, All Suppose this sitiuation DB Tables: A(ida, desc) , B(idb, ida,
>> desc)
>> Java Classes: public class A{ String ida; String desc; List
>> * Bs; } public class B{String idb; String desc; A parentA;} I am new to
>> iBatis and I am trying to work around this problem. But I couldn't find
>> any
>> examples , please any one can help me in this THANKS
>> ------------------------------
>> View this message in context: HELP NEEDED : Bidirectional
>> associations<http://www.nabble.com/HELP-NEEDED-%3A-Bidirectional-associations-tp23482686p23482686.html>
>> Sent from the iBATIS - User - Java mailing list
>> archive<http://www.nabble.com/iBATIS---User---Java-f370.html>at
>> Nabble.com.
>> *
> 
> 

-- 
View this message in context: http://www.nabble.com/HELP-NEEDED-%3A-Bidirectional-associations-tp23482686p23497323.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: HELP NEEDED : Bidirectional associations

Posted by Clinton Begin <cl...@gmail.com>.
Currently, the trick is to ensure that you have caching enabled for those
statements (caching of any configuration, other than weak reference caching,
will work).
This is not ideal and is solved by iBATIS 3.0, which is just around the
corner.

Clinton

On Mon, May 11, 2009 at 6:54 AM, RO86 <ra...@yahoo.com> wrote:

> Hi, All Suppose this sitiuation DB Tables: A(ida, desc) , B(idb, ida, desc)
> Java Classes: public class A{ String ida; String desc; List
> * Bs; } public class B{String idb; String desc; A parentA;} I am new to
> iBatis and I am trying to work around this problem. But I couldn't find any
> examples , please any one can help me in this THANKS
> ------------------------------
> View this message in context: HELP NEEDED : Bidirectional associations<http://www.nabble.com/HELP-NEEDED-%3A-Bidirectional-associations-tp23482686p23482686.html>
> Sent from the iBATIS - User - Java mailing list archive<http://www.nabble.com/iBATIS---User---Java-f370.html>at Nabble.com.
> *