Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ibatis to pull values from dual defined in stored proc

 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a stored procedure with return item defined SYS_REFCURSOR. With in stored proc, the cursor is reading values from dual table. I need to read these values which are present in the dual table using Ibatis into java object. When I map these values present in dual table to <ResultMap> I get exception. Below is the outline...

procedure example1(....., ...., outputvalues OUT sys_refcursor, ......)
...
BEGIN
... OPEN outputvalues FOR
select x.value1, x.value2 from DUAL;
.....

<parameterMap .........>
<parameter property="outputvalues" jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" resultMap="outValues" />
</parameterMap>

<resultMap id="outValues" class="DAOValues">
<result property="daovalue1" column="value1" />
<result property="daovalue2" column="value2" />
</resultMap>

daoValue1 & daoValue 2 are attributes in DAOValues class.
When I try to execute the stored proc, I'm getting error saying "daovalue1" is not defined. Can anyone tell me how to define the column values properly so I can avoid this problem.

Thanks,
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


should be



Same for daovalue2.
 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still same error.
Check the outValues
Check the result Mapping for the outValue1 property.
Cause: java.sql.SQLException: Invalid column name.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it isn't the same error, this time it is complaining about value1 within the PLSQL block.

Are you able to run this procedure on its own, say with something like PLSQL Developer?
 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you may need to define your ibatis config differently. Something like the following.



I think the important bit you have missed is defining the mode of each parameter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic