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 "Stevens, Ian" <IS...@globeandmail.com> on 2009/07/16 21:09:39 UTC
Implicit map/list for result set of stored procedure call?
I'm trying to grab data from an Oracle stored procedure using iBatis
2.3.4. I have something like the following in my XML:
<resultMap id="result" class="hashmap">
<result property="year" column="YEAR"/>
</resultMap>
<parameterMap id="params" class="map">
<parameter property="po_rc" javaType="java.sql.ResultSet"
jdbcType="ORACLECURSOR" mode="OUT" resultMap="result"/>
<parameter property="po_rec_cnt" javaType="java.lang.Long"
jdbcType="BIGINT" mode="OUT"/>
<parameter property="po_currency_flag"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="pi_company_id" jdbcType="NUMBER"
javaType="java.lang.Long" mode="IN"/>
</parameterMap>
<procedure id="getData" parameterMap="params">
{call pkg.foo(?,?,?,?)}
</procedure>
There are a number of columns in the result set. Is it possible to have
the procedure implicitly populate a map with each row of the results? or
do I have to explicitly specify mappings for each column like I did with
YEAR above? I just need the values in the order they appear as columns.
Better still, can I have the result populated as a list of lists, one
list per row containing the values of the columns in order?
thanks,
Ian.
RE: Implicit map/list for result set of stored procedure call?
Posted by "Stevens, Ian" <IS...@globeandmail.com>.
I partly figured this one out, and that's good enough for me. The
modified version of the XML follows. The code I was modifying made use
of SqlMapClient.queryForObject(). What I needed was
SqlMapClient.queryForList().
<parameterMap id="params" class="map">
<parameter property="po_rc" javaType="java.sql.ResultSet"
jdbcType="ORACLECURSOR" mode="OUT"/>
<parameter property="po_rec_cnt" javaType="java.lang.Long"
jdbcType="BIGINT" mode="OUT"/>
<parameter property="po_currency_flag"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="pi_company_id" jdbcType="NUMBER"
javaType="java.lang.Long" mode="IN"/>
</parameterMap>
<procedure id="getData" parameterMap="params"
resultClass="java.util.LinkedHashMap">
{call pkg.foo(?,?,?,?)}
</procedure>
Ian.
________________________________
From: Stevens, Ian [mailto:IStevens@globeandmail.com]
Sent: July 20, 2009 1:11 PM
To: user-java@ibatis.apache.org
Subject: RE: Implicit map/list for result set of stored
procedure call?
Am I to understand that iBatis needs a column name mapping,
otherwise no columns are stored in the map? There's no way to
short-circuit this behaviour and just place the columns in a hash map
keyed on the original column names? I need a more dynamic map as the
stored procedure I am using returns a different cursor depending on the
results. Any suggestions?
thanks,
Ian.
________________________________
From: Stevens, Ian [mailto:IStevens@globeandmail.com]
Sent: July 16, 2009 3:10 PM
To: user-java@ibatis.apache.org
Subject: Implicit map/list for result set of stored
procedure call?
I'm trying to grab data from an Oracle stored procedure
using iBatis 2.3.4. I have something like the following in my XML:
<resultMap id="result" class="hashmap">
<result property="year" column="YEAR"/>
</resultMap>
<parameterMap id="params" class="map">
<parameter property="po_rc"
javaType="java.sql.ResultSet" jdbcType="ORACLECURSOR" mode="OUT"
resultMap="result"/>
<parameter property="po_rec_cnt"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="po_currency_flag"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="pi_company_id"
jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
</parameterMap>
<procedure id="getData" parameterMap="params">
{call pkg.foo(?,?,?,?)}
</procedure>
There are a number of columns in the result set. Is it
possible to have the procedure implicitly populate a map with each row
of the results? or do I have to explicitly specify mappings for each
column like I did with YEAR above? I just need the values in the order
they appear as columns.
Better still, can I have the result populated as a list
of lists, one list per row containing the values of the columns in
order?
thanks,
Ian.
RE: Implicit map/list for result set of stored procedure call?
Posted by "Stevens, Ian" <IS...@globeandmail.com>.
Am I to understand that iBatis needs a column name mapping, otherwise no
columns are stored in the map? There's no way to short-circuit this
behaviour and just place the columns in a hash map keyed on the original
column names? I need a more dynamic map as the stored procedure I am
using returns a different cursor depending on the results. Any
suggestions?
thanks,
Ian.
________________________________
From: Stevens, Ian [mailto:IStevens@globeandmail.com]
Sent: July 16, 2009 3:10 PM
To: user-java@ibatis.apache.org
Subject: Implicit map/list for result set of stored procedure
call?
I'm trying to grab data from an Oracle stored procedure using
iBatis 2.3.4. I have something like the following in my XML:
<resultMap id="result" class="hashmap">
<result property="year" column="YEAR"/>
</resultMap>
<parameterMap id="params" class="map">
<parameter property="po_rc"
javaType="java.sql.ResultSet" jdbcType="ORACLECURSOR" mode="OUT"
resultMap="result"/>
<parameter property="po_rec_cnt"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="po_currency_flag"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="pi_company_id" jdbcType="NUMBER"
javaType="java.lang.Long" mode="IN"/>
</parameterMap>
<procedure id="getData" parameterMap="params">
{call pkg.foo(?,?,?,?)}
</procedure>
There are a number of columns in the result set. Is it possible
to have the procedure implicitly populate a map with each row of the
results? or do I have to explicitly specify mappings for each column
like I did with YEAR above? I just need the values in the order they
appear as columns.
Better still, can I have the result populated as a list of
lists, one list per row containing the values of the columns in order?
thanks,
Ian.
RE: Implicit map/list for result set of stored procedure call?
Posted by "Stevens, Ian" <IS...@globeandmail.com>.
FYI, I'm now using a linkedhashmap instead of hashmap for the resultMap,
but still need to specify all the columns as results.
Ian.
________________________________
From: Stevens, Ian [mailto:IStevens@globeandmail.com]
Sent: July 16, 2009 3:10 PM
To: user-java@ibatis.apache.org
Subject: Implicit map/list for result set of stored procedure
call?
I'm trying to grab data from an Oracle stored procedure using
iBatis 2.3.4. I have something like the following in my XML:
<resultMap id="result" class="hashmap">
<result property="year" column="YEAR"/>
</resultMap>
<parameterMap id="params" class="map">
<parameter property="po_rc"
javaType="java.sql.ResultSet" jdbcType="ORACLECURSOR" mode="OUT"
resultMap="result"/>
<parameter property="po_rec_cnt"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="po_currency_flag"
javaType="java.lang.Long" jdbcType="BIGINT" mode="OUT"/>
<parameter property="pi_company_id" jdbcType="NUMBER"
javaType="java.lang.Long" mode="IN"/>
</parameterMap>
<procedure id="getData" parameterMap="params">
{call pkg.foo(?,?,?,?)}
</procedure>
There are a number of columns in the result set. Is it possible
to have the procedure implicitly populate a map with each row of the
results? or do I have to explicitly specify mappings for each column
like I did with YEAR above? I just need the values in the order they
appear as columns.
Better still, can I have the result populated as a list of
lists, one list per row containing the values of the columns in order?
thanks,
Ian.