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 Stephen Boyd <sw...@gmail.com> on 2007/08/08 02:19:38 UTC

statementCachingEnabled

If I reuse prepared statements in nested queries and statement caching is
on, then I potentially will have results sets closed prematurely.  The
reason is that the PreparedStatement.executeQuery() will close any
previously opened result sets.  Are there many people out there using these
types of recursive calls.  If so, should there be a mechanism to handle this
case so that we can still use the global statement caching for the rest of
the application?  Below is an example of a sqlmap.


<resultMap id="getTreeNodeResultMap" class="TreeNode"  >
      <result property="id"        column="id"       jdbcType="INTEGER"
 javaType="int"    />
      <result property="name" column="name"  jdbcType="VARCHAR"
 javaType="string"    />
      <result property="childNodes"  column="{parentId=ID}"
select="getNodeChildren" />
 </resultMap>

 <select id="getNodeRoot" resultMap="getTreeNodeResultMap" >
      select id, name
         from org
         where parent_id is null
  </select>

  <select id="getNodeChildren" resultMap="getTreeNodeResultMap" >
      select id, name
         from org
         where parent_id = #parentId#
  </select>

Regards,
Stephen