【发布时间】:2022-01-20 02:03:02
【问题描述】:
我的应用程序中有一个像这样的 Mapper 类,它试图调用数据库中的过程,我检查了 3000 次类型和位置 og 参数是否正确,但它抛出和 sqlException,现在我会向你展示映射器的代码
@Mapper
public interface HoraFechaExtractoMapper {
@Select(value="{ CALL PACKAGE.PROCEDURE("
+ "#{P_tpno, mode=IN, jdbcType=VARCHAR},"
+ "#{Registro.pPeriodicidad, mode=OUT, jdbcType=VARCHAR},"
+ "#{Registro.pHora, mode=OUT, jdbcType=VARCHAR},"
+ "#{Registro.pDia, mode=OUT, jdbcType=NUMERIC})}")
public void getHoraFechaExtracto(@Param("P_tpno") String p_tpno,@Param("Registro") Registro registro);
}
作为methos Mapper的参数的My Registro Class是这样的
public class Registro implements Serializable{
/**
*
*/
private static final long serialVersionUID = 2014497735552490495L;
/** The p periodicidad. */
@JsonProperty("p_periodicidad")
private String pPeriodicidad;
/** The p hora. */
@JsonProperty("p_hora")
private String pHora;
/** The p dia. */
@JsonProperty("p_dia")
private Integer pDia;
/**
* Gets the p periodicidad.
*
* @return the p periodicidad
*/
public String getpPeriodicidad() {
return pPeriodicidad;
}
/**
* Sets the p periodicidad.
*
* @param pPeriodicidad the new p periodicidad
*/
public void setpPeriodicidad(String pPeriodicidad) {
this.pPeriodicidad = pPeriodicidad;
}
/**
* Gets the p hora.
*
* @return the p hora
*/
public String getpHora() {
return pHora;
}
/**
* Sets the p hora.
*
* @param pHora the new p hora
*/
public void setpHora(String pHora) {
this.pHora = pHora;
}
/**
* Gets the p dia.
*
* @return the p dia
*/
public Integer getpDia() {
return pDia;
}
/**
* Sets the p dia.
*
* @param pDia the new p dia
*/
public void setpDia(Integer pDia) {
this.pDia = pDia;
}
}
但是Mybatis在准备语句的时候会抛出这个错误
### The error occurred while setting parameters
### SQL: { CALL PACKAGE.PROCEDURE(?,?,?,?)}
### Cause: java.sql.SQLException: Missing IN or OUT parameter at index:: 2
Caused by: org.apache.ibatis.exceptions.PersistenceException:
错误很可能在mapper中,但我找不到错误,也许你能看到它
【问题讨论】:
-
第二个参数的“参数方式”是什么?如果是
IN,那么从Java 执行调用应该很容易;从数据库引擎外部调用其他任何内容(如OUT或INOUT)都可能很棘手。 -
什么是数据库?看起来像甲骨文。
-
这是过程的门面 -> 过程过程( p_tpno in varchar2, p_periodicidad out varchar2, p_hora out varchar2, p_dia out number )
-
谢谢它是缺少选项注释