title: Java MyBatis stored procedure call with OUT parameters
body: <p><strong>First question:</strong>
  I am trying to return one OUT parameter and not a result set with annotations. First, is it even possible? If it is, how would one do this?</p>
  
  <p>MyBatis: 3.0.6</p>
  
  <p>Database: SQL Server 2008</p>
  
  <p>Here is an example of the syntax of my method call in the UserDAO:</p>
  
  <pre><code>@Select(value= "{ CALL saveUser( "
          + "#{userId, mode=IN, jdbcType=INTEGER},"
          + "#{firstname, mode=IN, jdbcType=VARCHAR},"
          + "#{lastname, mode=IN, jdbcType=VARCHAR},"
          + "#{message, mode=OUT, jdbcType=VARCHAR}"
          + ")}")
  @Options(statementType=StatementType.CALLABLE)
  public String saveUser(
          @Param("userId") int userId,
          @Param("firstname") String firstname,
          @Param("lastname") String lastname);
  </code></pre>
  
  <p>I am returning a message from all of my "save" procedures and so I can return a response to the user: "User save successfully","Error saving user","You do not have permission to save this user", etc. I know that returning a result set will solve the problem, its just that I don't want to change all of my procedures!</p>
  
  <p><strong>Second question:</strong> Is it possible to return a "SaveProcedureResponse" populated from multiple OUT parameters? For example:</p>
  
  <pre><code>@Select(value= "{ CALL saveUser( "
          + "#{userId, mode=IN, jdbcType=INTEGER},"
          + "#{firstname, mode=IN, jdbcType=VARCHAR},"
          + "#{lastname, mode=IN, jdbcType=VARCHAR},"
          + "#{message, mode=OUT, jdbcType=VARCHAR},"
          + "#{status, mode=OUT, jdbcType=VARCHAR},"
          + "#{returnCode, mode=OUT, jdbcType=INTEGER}"
          + ")}")
  @Options(statementType=StatementType.CALLABLE)
  public SaveProcedureResponse saveUser(
          @Param("userId") int userId,
          @Param("firstname") String firstname,
          @Param("lastname") String lastname);
  </code></pre>
  
  <p>Where the bean looks like this:</p>
  
  <pre><code>public class SaveProcedureResponse {
      private String message;
      private String status;
      private int returnCode;
  
      public SaveProcedureResponse(String message, String status, int returnCode) {
          this.message = message;
          this.status = status;
          this.returnCode = returnCode;
      }
  }
  </code></pre>
  
  <p>Thanks!</p>