我正在使用 Mybatis 3.2.6 并实现自定义结果处理程序。在使用简单的数据类型参数之前,我已经完成了这项工作,并且没有遇到任何问题。这一次我需要传入几个参数......我使用的签名是
session.select(statement, parameter, handler);
对于参数,我创建了一个简单的 POJO 来轻松发送我需要的内容。如下:
public class DifferenceParam {
private int current;
private int compare;
private String table;
private String comparator;
/**
* Constructor excluding comparator. Will default a value of
* "code" to compare content on, e.g., <br/>
* {@code select * from a minus select * from b where a.code = b.code } <br/>
* @param table
* @param current
* @param compare
*/
public DifferenceParam(String table, int current, int compare) {
this(table, "code", current, compare);
}
/**
* Constructor providing a specific column to compare on, e.g. <br/>
* {@code select * from a minus select * from b where a.[comparator] = b.[comparator] } <br/>
* @param table
* @param comparator
* @param current
* @param compare
*/
public DifferenceParam(String table, String comparator, int current, int compare) {
this.table = table;
this.comparator = comparator;
this.current = current;
this.compare = compare;
}
/** Appropriate setters and getters to follow **/
}
处理程序实现目前无关紧要,因为我提前得到了一个异常......我正在执行的查询是:
<select id="getCodeSetModifications" parameterType="DifferenceParam" resultType="Code">
select *
from
(
select * from ${param.table} where revision_seq = #{param.current}
minus
select * from ${param.table} where revision_seq = #{param.compare}
) a, ${param.table} b
where a.${param.comparator} = b.${param.comparator}
and b.revision_seq = #{param.compare}
</select>
这里也是界面
public List<Code> getCodeSetModifications(@Param("param") DifferenceParam param);
我遇到的问题是通过映射器执行,例如,
session.getMapper(DifferenceParam.class);
工作得很好,但是当我通过会话上的选择调用时,我得到以下异常。
Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'param' in 'class com.mmm.his.cer.cerval.uidifference.map.param.DifferenceParam'
Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'param' in 'class com.mmm.his.cer.cerval.uidifference.map.param.DifferenceParam'
我已经尽可能地调试了 Mybatis,但没有运气。
提前致谢...