ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Reelsen" <...@emplify.de>
Subject Novice problem with circular dependencies
Date Fri, 19 Mar 2010 12:43:20 GMT
Hi

I am currently playing around with ibatis and stuck with bidirectional
associations/circular dependencies - after googling a little bit around my
understanding is, that it should work, when caching/lazy loading is
enabled.

So, consider the following java classes for small example:


class Campaign {
     Integer id;
     String name;
     List<Target> targets;
}

class Target {
     Integer id;
     String name;
     String email;
     Campaign campaign;
}

This is basically the bidirectional association. Spoken from the
application point of view something like
  user.getCampaign().getUsers().get(0).getCampaign()
should work.

>From the ibatis point of view I seem not to have understand yet correctly
how to handle that.

Here are my resultMaps

<resultMap id="campaignTargetMap" type="Target">
  <id property="id" column="target_id" />
  <result property="name" column="target_name" />
  <result property="email" column="target_email" />

  <association property="campaign" resultMap="campaignResultMap" />
</resultMap>

<resultMap id="campaignResultMap" type="Campaign">
  <id property="id" column="campaign_id" />
  <result property="name" column="campaign_name" />

  <collection property="targets" ofType="Target"
resultMap="campaignTargetMap" />
</resultMap>

However I keep getting a stackoverflow error, indicating that it does not
work, when I call something like the java code above.

Here goes the exception:

java.lang.StackOverflowError
at
com.mysql.jdbc.ConnectionImpl.getCharsetConverter(ConnectionImpl.java:2904)
at com.mysql.jdbc.ResultSetRow.getString(ResultSetRow.java:793)
at com.mysql.jdbc.ByteArrayRow.getString(ByteArrayRow.java:72)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5700)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5577)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5617)
at
org.apache.ibatis.type.StringTypeHandler.getNullableResult(StringTypeHandler.java:17)
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:24)
at
org.apache.ibatis.executor.resultset.FastResultSetHandler.getPropertyMappingValue(FastResultSetHandler.java:225)
at
org.apache.ibatis.executor.resultset.FastResultSetHandler.applyPropertyMappings(FastResultSetHandler.java:208)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.getRowValue(NestedResultSetHandler.java:106)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.applyNestedResultMappings(NestedResultSetHandler.java:136)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.getRowValue(NestedResultSetHandler.java:107)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.applyNestedResultMappings(NestedResultSetHandler.java:136)
at
org.apache.ibatis.executor.resultset.NestedResultSetHandler.getRowValue(NestedResultSetHandler.java:107)

[from here the last two lines keep alternating]


I put a quick look at ibatis jira issues 760[1] and 427[2], but that
didn't help me so far.


Regards and many thanks for any insightful pointers,
Alexander

[1] https://issues.apache.org/jira/browse/IBATIS-760
[2] https://issues.apache.org/jira/browse/IBATIS-427

-- 
http://www.emplify.de


---------------------------------------------------------------------
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