索引处缺少 IN 或 OUT 参数:: 2 ERROR with Mybatis
Missing IN or OUT parameter at index:: 2 ERROR with Mybatis
我的应用程序中有一个像这样的 Mapper class,它试图调用数据库中的过程,我检查了 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);
}
我的 Registro Class 是 methos Mapper 的参数,就像这样
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的错误,但是我找不到错误,也许你能看到它
也许你需要
@Options(statementType = StatementType.CALLABLE)
在 Select 注释之后
我的应用程序中有一个像这样的 Mapper class,它试图调用数据库中的过程,我检查了 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);
}
我的 Registro Class 是 methos Mapper 的参数,就像这样
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的错误,但是我找不到错误,也许你能看到它
也许你需要
@Options(statementType = StatementType.CALLABLE)
在 Select 注释之后