UPDATE:
Sorry if this double posts. I sent this out via email earlier and never saw it show up on the forum; now resubmitting through the browser interface. I've since solved part of this issue, but am not completely out of the water.
I had to pass the mapper interface method a reference to the POJO type I was looking to use for the result (StagingManagement) to get rid of this error. The issue I'm having now is the result is not surfacing in the POJO. It comes back null. When I step through in the debugger, I can see it's getting set deep under the hood, but it's just not surfacing correctly.
StagingManagement stagmag = new StagingManagement();
stagmag = lmsSqlSession.selectOne("callEtlDoBatch", stagmag);
System.out.println("<<Done>>");
System.out.println(stagmag.getDoBatchResult());
import com.workplace.staging.somesystem.data.domain.StagingManagement;
public interface StagingManagementMapper {
//public String callEtlDoBatch();
public StagingManagement callEtlDoBatch(StagingManagement doBatchResult);
}
I'm struggling with the idea that calling a simple stored proc with a String return value is this difficult in MyBatis. Everything else has always worked well and be fairly easy to understand/deal with.
Any help would be greatly appreciated. There is definitely some things I'm not quite understanding with regard to MyBatis and stored procs.
<<<<<<<<<<<<<<<<< OLD POST >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Hi everyone. I'm trying to add in stored procedure calls to a MyBatis application we have and am able to get them to execute, however, when MyBatis tries to map the results back into the Pojo I have coded I get:
Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property 'doBatchResult' of 'class java.lang.Class' with value '
My code is below. I'd appreciate any help with this. The docs don't cover stored procs hardly at all and much of what I find in web searches show use cases that aren't like mine and I'm out of gas trying to figure this out; been stuck for a day and a half on this. The closest I could find was this blog:
http://java.dzone.com/articles/ibatis-mybatis-working-stored, however, these examples in context to my code didn't work either. The code below shows a resultMap being used, but I've tried parameter maps, and just using resultType to let MyBatis figure it out, and more. None has worked so far.
It's pretty simple. I have one stored proc located on a Postgresql 9.1 machine that I need to call. It only has one out param that returns a long string with the results of the operation. That's it.
<<<<<<<<<<<<<<<<<<< MODEL POJO >>>>>>>>>>>>>>>>>>>>>>>>>>>
public class StagingManagement {
private String doBatchResult;
public String getDoBatchResult() {
return doBatchResult;
}
public void setDoBatchResult(String doBatchResult) {
this.doBatchResult = doBatchResult;
}
}
<<<<<<<<<<<<<<<<<<< MAPPER INTERFACE >>>>>>>>>>>>>>>>>>>>>>>>>>>
package com.workplace.staging.somesystem.data.client;
import com.workplace.staging.somesystem.data.domain.StagingManagement;
public interface StagingManagementMapper {
public StagingManagement callEtlDoBatch();
}
<<<<<<<<<<<<<<<<<<< MAPPER FILE >>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//
mybatis.org//DTD Mapper 3.0//EN" "
http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.workplace.staging.somesystem.data.client.StagingManagementMapper">
<resultMap id="ProcResultMap" type="com.workplace.staging.somesystem.data.domain.StagingManagement">
<result column="result" jdbcType="VARCHAR" property="doBatchResult"/>
</resultMap>
<select id="callEtlDoBatch" useCache="false" resultMap="ProcResultMap" statementType="CALLABLE">
{ CALL staging.etl_do_batch(#{doBatchResult, mode=OUT, jdbcType=VARCHAR})}
</select>
</mapper>
<<<<<<<<<<<<<<<<<<< EXCEPTION OUTPUT >>>>>>>>>>>>>>>>>>>>>>>>>>>
Batch ID 681 Complete.' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'doBatchResult' in 'class java.lang.Class'
at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:175)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:57)
at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:133)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleOutputParameters(DefaultResultSetHandler.java:117)
at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:68)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.BatchExecutor.doQuery(BatchExecutor.java:87)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
... 7 more
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'doBatchResult' in 'class java.lang.Class'
at org.apache.ibatis.reflection.Reflector.getSetInvoker(Reflector.java:372)
at org.apache.ibatis.reflection.MetaClass.getSetInvoker(MetaClass.java:174)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:167)
... 18 more
Thanks,
Daniel