Oracle存储过程:
create or replace PROCEDURE "TGT_MPD_PLANOGRAM_SEL_SP" (
POG_NUM_IN IN VARCHAR2,
PLAN_DATA_SEL_CUR OUT SYS_REFCURSOR,
SQL_CODE_OUT OUT NUMBER,
SQL_ERR_MSG_OUT OUT VARCHAR2)
AS
...
Mapper.xml
<select id="getPlanograms" statementType="CALLABLE"
parameterType="com.tgt.snp.pog.vo.PlanogramSearchVO"
resultMap="mapResultPlanogram">
{
CALL TGT_MPD_PLANOGRAM_SEL_SP(
#{POG_NUM_IN,javaType=String,jdbcType=VARCHAR,jdbcTypeName=VARCHAR2,mode=IN},
#{PLAN_DATA_SEL_CUR,jdbcType=CURSOR,resultMap=mapResultPlanogram,mode=OUT},
#{SQL_CODE_OUT,javaType=Integer,jdbcType=INTEGER,jdbcTypeName=INTEGER,mode=OUT},
#{SQL_ERR_MSG_OUT,javaType=String,jdbcType=VARCHAR,jdbcTypeName=VARCHAR2,mode=OUT}
)
}
</select>
VO对象
public class PlanogramSearchVO {
public PlanogramSearchVO(){}
public String getPOG_NUM_IN() {
return POG_NUM_IN;
}
public void setPOG_NUM_IN(String POG_NUM_IN) {
this.POG_NUM_IN = POG_NUM_IN;
}
private String POG_NUM_IN;
public ResultSet getPLAN_DATA_SEL_CUR() {
return PLAN_DATA_SEL_CUR;
}
public void setPLAN_DATA_SEL_CUR(ResultSet PLAN_DATA_SEL_CUR) {
this.PLAN_DATA_SEL_CUR = PLAN_DATA_SEL_CUR;
}
private ResultSet PLAN_DATA_SEL_CUR;
public Integer getSQL_CODE_OUT() {
return SQL_CODE_OUT;
}
public void setSQL_CODE_OUT(Integer SQL_CODE_OUT) {
this.SQL_CODE_OUT = SQL_CODE_OUT;
}
private Integer SQL_CODE_OUT;
public String getSQL_ERR_MSG_OUT() {
return SQL_ERR_MSG_OUT;
}
public void setSQL_ERR_MSG_OUT(String SQL_ERR_MSG_OUT) {
this.SQL_ERR_MSG_OUT = SQL_ERR_MSG_OUT;
}
private String SQL_ERR_MSG_OUT;
}
错误消息
Caused by: org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: java.sql.SQLException: Non supported SQL92 token at position: 1:
### The error may exist in class path resource [PlanogramMapper.xml]
### The error may involve com.tgt.snp.pog.mapper.PlanogramMapper.getPlanograms-Inline
### The error occurred while setting parameters
### SQL: { ?, ?, ? = CALL TGT_MPD_PLANOGRAM_SEL_SP( ? ) }
### Cause: java.sql.SQLException: Non supported SQL92 token at position: 1:
; uncategorized SQLException for SQL []; SQL state [99999]; error code [17034]; Non supported SQL92 token at position: 1: ; nested exception is java.sql.SQLException: Non supported SQL92 token at position: 1:
请指出我错了什么?提前谢谢。
答案 0 :(得分:1)
<select>
元素不需要resultMap
属性,因为这里没有使用它:调用带有out参数的过程,即使它们是cursor / resultSet,也不是 SELECT < / em>的
您可能需要在参数定义中将java类型指定为结果集:
#{PLAN_DATA_SEL_CUR, jdbcType=CURSOR, javaType=java.sql.ResultSet, resultMap=mapResultPlanogram, mode=OUT}
类PlanogramSearchVO
中的属性PLAN_DATA_SEL_CUR不能是java.sql.ResultSet
,而是List<Planogram>
,如果结果映射mapResultPlanogram
将游标结果映射到Planogram
对象
Mybatis正在完成将resultSet / Cursor读取/映射到对象列表的工作;缺点是只有在光标被完全取出时才返回控件:没有自定义结果处理,懒惰/不同加载,......我有answered another question about this。