Hi!
I am trying to get Oracle stored functions to work with mybatis 3.0.4,
without success.
I started from the example at
http://mybatis.googlecode.com/svn/trunk/src/test/java/org/apache/ibatis/submitted/refcursor
And come up with this:
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.math.BigDecimal" >
<!-- this is @mbggenerated - I am trying to get the same function
by a stored function -->
select
<include refid="Base_Column_List" />
from USER1.EVENTS
where EVENT_ID = #{eventId,jdbcType=DECIMAL}
</select>
<update id="selectByPrimaryKeySP" parameterType="map"
statementType="CALLABLE">
{ #{order,jdbcType=CURSOR,mode=OUT,resultMap=BaseResultMap,javaType=java.sql.ResultSet}
=
call USER1.loadEventHB(#{eventId,jdbcType=DECIMAL,mode=IN}) }
</update>
The calling code is:
Map<String, Object> parameter = new HashMap<String, Object>();
parameter.put("eventId", new java.math.BigDecimal(23));
int res = sqlSession.update("foo.EventsMapper.selectByPrimaryKeySP",
parameter);
The log and exceptions are:
00:47:00.840 [main] DEBUG java.sql.Connection - ooo Connection Opened
00:47:01.199 [main] DEBUG java.sql.PreparedStatement - ==> Executing:
{ ? = call USER1.loadEventHB(?) }
00:47:01.199 [main] DEBUG java.sql.PreparedStatement - ==> Parameters:
23(BigDecimal)
00:47:01.215 [main] DEBUG java.sql.Connection - xxx Connection Closed
00:47:01.215 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Returned
connection 15842168 to pool.
Exception in thread "main"
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.sql.SQLException: Malformed
SQL92 string at position: 6. Expecting "call"
### The error may involve foo.EventsMapper.selectByPrimaryKeySP-Inline
### The error occurred while setting parameters
The same SQL ( "{ ? = call USER1.loadEventHB(?) }" ) works fine when
used with hibernate or from Oracle sqlPlus tool.
Any idea what is going on?
I suspect the function return parameter (the first question mark) is
not set up properly.
Regards,
David