ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bhaarat Sharma <bhaara...@gmail.com>
Subject iBatis doesnt put object into the list when cursor returns no rows
Date Tue, 10 Nov 2009 19:31:37 GMT
I am running a stored procedure that returns 2 cursors and none of them have
any data. I have the following mapping xml: <resultMap id="resultMap1"
class="HashMap"> <result property="firstName" columnIndex="2"/> </resultMap>
<resultMap id="resultMap2" class="com.somePackage.MyBean"> <result
property="unitStreetName" column="street_name"/> </resultMap> <parameterMap
id="parmmap" class="map"> <parameter property="id" jdbcType="String"
javaType="java.lang.String" mode="IN"/> <parameter property="Result0"
jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT"
resultMap="resultMap1"/> <parameter property="Result1"
jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT"
resultMap="resultMap2"/> </parameterMap> <procedure id="proc"
parameterMap="parmmap"> { call my_sp (?,?,?) } </procedure> First result set
is being put in a HashMap...second resultSet is being put in a `MyBean`
class. code in my DAO follows: HashMap map = new HashMap() map.put("id",
"1234"); getSqlMapClientTemplate().queryForList("mymap.proc", map); HashMap
result1 = (HashMap)((List)parmMap.get("Result0")).get(0); MyBean myObject =
(MyBean)((List)parmMap.get("Result1")).get(0);//code fails here in the last
line above..my code fails. It fails because second cursor has no rows and
thats why nothing is put into the list. However, first cursor returns
nothing as well but since results are being put into a `HashMap` the list
for first cursor atleast has `HashMap` object inside it.. Why this
difference? is there a way to make iBatis put an object of MyBean inside the
list even if there are no rows returned? Or should I be handling this in my
DAO...I want to avoid handling it in the DAO because I have whole bunch of
DAO's like these.

Mime
View raw message