ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Boyd" <swb...@gmail.com>
Subject statementCachingEnabled
Date Wed, 08 Aug 2007 00:19:38 GMT
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

Mime
View raw message