Search code examples
parameter-passingdaomybatisprocedureibatis

Mybatis + stored procedure - How to Pass a long value to a procedure using mybatis


I read up most of the websites with examples and the mybatis documentation. I am definitely missing something simple and am going to look really stupid.

Can someone please take a look at why this procedure does not even get called when my DAO invokes the id?

Here is what I added to my .xml file.

<parameterMap id="validateProcedure_paramMap" class="java.lang.Long">
  <parameter property="requestId" jdbcType="NUMERIC"  mode="IN">
</parameterMap> 
<!--  Calls stored procedure -->

<procedure id="validateRequest" parameterMap="validateProcedure_paramMap">
{call NG_PKG.validateRequest_sp(?)}
</procedure>

I just call it normally via the DAO. The DAO is getting the long parameter passed in

 public void validateRequest(long reqId) throws SQLException
{       

    sqlMap.queryForObject("validateRequest", reqId);

}

Can someone see if I am doing anything wrong - and what is it that I am doing wrong :( Control just goes over the DAObut does the procedure is not getting called in the database.


Solution

  • Sorry, Folks I should have posted what I found out.

    I was looking in the wrong place. My procedure seems to have been getting called. It is just that my transaction handling that was being done was not committing this part of it.

    I had a separate method that has a starttransaction and a commit transaction and an endtransaction using the ibatis SQLTransactionManager.

    The method that calls this stored procedure gets called after that. For some reason, it wouldn't commit this. I removed the endtransaction on the different method and am only ending it in one palce - which is actually what I want. I only want to commit at the end of the validation procedure anyways. So, it works after I played around with my transactionmanagement.