MyBatis annotations to call Stored Procedure and get Out Params

大城市里の小女人 提交于 2019-11-28 09:27:39

问题


I am using MyBAtis-3 with MyBAtis-Spring. When i tried to call a stored procedure that returns more than one out params using MyBatis annotations. I don't get anything, I can see that the input parameter is passed to the SP in the logs and it hangs in there with no progress nor exception thrown.

PFB the Oracle Stored Procedure which i am trying to access from MyBAtis,

create or replace PROCEDURE C2C.GET_DATA
(
  "IN_PARAM1" IN NUMBER,
   "OUT_PARAM2" OUT SAMPLETABLE.COL2%TYPE,
   "OUT_PARAM3" OUT SAMPLETABLE.COL3%TYPE,
   "OUT_PARAM4" OUT SAMPLETABLE.COL4%TYPE
  )  AS

  BEGIN
    SELECT PARAM2,PARAM3,PARAM4 INTO 
    OUT_PARAM2,OUT_PARAM3,OUT_PARAM4
    FROM C2C.SAMPLETABLE WHERE PARAM1=IN_PARAM1 ;  

  END C2C.GET_DATA;

PFB the mapper interface method,

@Select(value= "{ CALL  C2C.GET_DATA( #{param1, mode=IN, jdbcType=INTEGER},#{param2, mode=OUT, jdbcType=VARCHAR},#{param3, mode=OUT, jdbcType=INTEGER},#{param4, mode=OUT, jdbcType=INTEGER})}")
@Options(statementType = StatementType.CALLABLE)
public void getData(Test test);

The Test object contains the parameters passed as input in the Stored Procedure Call statement.

When i execute this, it gets hanged over here,

main Slf4jImpl 
==>  Preparing: { CALL C2C.GET_DATA(?,?,?,?)} 

main Slf4jImpl 
==> Parameters: 60(Integer)

回答1:


Surprisingly if i use @Insert annotation it is working as expected. Some weird behavior while calling Stored Procedures. Let me know if any one else has a good solution other than this.



来源:https://stackoverflow.com/questions/24910795/mybatis-annotations-to-call-stored-procedure-and-get-out-params

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!