【问题标题】:Missing IN or OUT parameter at index:: 2 ERROR with Mybatis索引处缺少 IN 或 OUT 参数:: 2 Mybatis 错误
【发布时间】: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 执行调用应该很容易;从数据库引擎外部调用其他任何内容(如OUTINOUT)都可能很棘手。
  • 什么是数据库?看起来像甲骨文。
  • 这是过程的门面 -> 过程过程( p_tpno in varchar2, p_periodicidad out varchar2, p_hora out varchar2, p_dia out number )
  • 谢谢它是缺少选项注释

标签: java sql spring mybatis


【解决方案1】:

也许你需要

@Options(statementType = StatementType.CALLABLE)

选择注解后

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-19
    • 2018-01-31
    • 2014-04-26
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    相关资源
    最近更新 更多