1

我需要使用注释在 MyBatis 中调用 Oracle 函数。

我的映射器:

@Select("{ CALL #{outParam, jdbcType=NUMERIC, mode=OUT} := ORA_FUNC( "
    + "#{pNum1, jdbcType=NUMERIC, mode=IN},"
    + "#{pNum2, jdbcType=NUMERIC, mode=IN},"
    + "#{pNum3, jdbcType=NUMERIC, mode=IN} )}")
@Options(statementType = StatementType.CALLABLE)
@ResultType(Integer.class)
public Integer executeFunction(
    @Param("map") Map<String, Object> carteira);

和我对这个签名的呼吁:

Map<String, Object> mapParameters = new HashMap<String, Object>();
mapParameters.put("pNum1", carteira.getUnimedCarteira());
mapParameters.put("pNum2", carteira.getCodCarteira());
mapParameters.put("pNum3", carteira.getDigitoCarteira());
mapper.obterRedeBeneficiario(mapParameters);
return mapParameters.get("outParam").toString();

outParam为空,mapper 的返回也为空

谁能帮我?

4

1 回答 1

2

创建域类 SpInOut 类

class SpInOut{

    private String outParam;
    private int pNum1;
    private int pNum2;
    private int pNum3;

    //Getters and setters

}

你可以改变你的maaper如下

@Select("{ #{outParam, jdbcType=NUMERIC, mode=OUT} = CALL ORA_FUNC( "
    + "#{pNum1, jdbcType=NUMERIC, mode=IN},"
    + "#{pNum2, jdbcType=NUMERIC, mode=IN},"
    + "#{pNum3, jdbcType=NUMERIC, mode=IN} )}")
@Options(statementType = StatementType.CALLABLE)
public void executeFunction(
    SpInOut inOut);
于 2014-11-06T14:37:45.227 回答