Dashboard > iBATIS DataMapper > Home > Improved Stored Procedure Support Whiteboard > Information > Page Comparison
Improved Stored Procedure Support Whiteboard
Version 1 by Jeff Butler
on Aug 09, 2005 10:48.

compared with
Current by Jeff Butler
on Sep 20, 2006 10:15.

(show comment)
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history

There are 1 changes. View first change.

 *This page is obsolete, as of iBATIS 2.2.0 we now support multiple result sets returned from queries and stored procedures so the need for this new function has reduced sharply.*
 h1. The Problem
 The traffic on the user's list regarding stored procedures has increased dramatically recently. This is partially because using procedures in iBATIS is not as intuitive as it could be. There are also at least 5 JIRA issues related to stored procedures (28, 96, 173, 176, 178). Some of these issues may be bugs, but some are related to support that cannot be offered given the current setup.
 h1. The Proposed Solution
 h2. New DTD Syntax
 Alter the DTD to allow syntax for declaring procedures something like this:
 h3. Option 1
 <storedProcedureParameterMap id="myParameterMap" class="map">
  <storedProcedureReturnCode property="rc" javaType="java.math.BigDecimal" jdbcType="DECIMAL" numericScale="2"/>
  <storedProcedureParameter property="num1" parameterName="@num1" javaType="java.math.BigDecimal" jdbcType="DECIMAL" mode="IN" />
  <storedProcedureParameter property="num2" parameterName="@num2" javaType=" java.math.BigDecimal" jdbcType="DECIMAL" mode="IN" />
  <storedProcedureParameter property="total" parameterName="@total" javaType="java.math.BigDecimal" jdbcType="DECIMAL" mode="OUT" numericScale="2" />
 <storedProcedureResultSets id="myResultSets">
  <storedProcedureResultSet resultClass="myresults.Result1" />
  <storedProcedureResultSet resultClass="myresults.Result2" />
 <storedProcedure id="myproc" procedureName="db2admin.MyProc" parameterMap="myParameterMap" resultSets="myResultSets" />
 This syntax allows unlimited paramters, allows use of parameter names (optional), allows multiple result sets, allows definition of a stored procedure return code.
 h3. Option 2
 <storedProcedure id="myproc2" procedureName="db2admin.MyProc" parameterClass="map" >
  <storedProcedureReturnCode property="rc" javaType="java.math.BigDecimal" jdbcType="DECIMAL" numericScale="2"/>
  <storedProcedureParameter property="num1" javaType="java.math.BigDecimal" jdbcType="DECIMAL" mode="IN" />
  <storedProcedureParameter property="num2" javaType=" java.math.BigDecimal" jdbcType="DECIMAL" mode="IN" />
  <storedProcedureParameter property="total" javaType="java.math.BigDecimal" jdbcType="DECIMAL" mode="OUT" numericScale="2" />
  <storedProcedureResultSet resultClass="myresults.Result1" />
  <storedProcedureResultSet resultClass="myresults.Result2" />
 This syntax is similar to the above, but more compact. Both options could be supported.
 h2. New Method for Stored Procedures
 Add a method "executeProcedure" to the existing SQLExecuter and SqlMapClient classes. This method would:
 # Compose the JDBC call statement from the procedure name and the specified parameters
 # Deal with parameters (set input parameters, register output parameters)
 # Execute the procedure
 # Deal with results - multiple ResultSets or UpdateCounts are allowed, we will consume everything the procedure spits back at us.
 # Get the output parameters, and possibly the return code
 The executeProcedure method would always return on object of type ProcedureResults (or similar).
 The ProcedureResults object looks like this:
 public class ProcedureResults &#123;
 &nbsp;&nbsp;&nbsp;&nbsp;private ArrayList results;
 &nbsp;&nbsp;&nbsp;&nbsp;private Object returnCode;
 &nbsp;&nbsp;&nbsp;&nbsp;//getters, setters, yada, yada...
 The results list contains Lists (in the case of ResultSets), or Integers(in the case of UpdateCounts). It would be up to the user to determine if the result was a List or an Integer - either dynamically with instanceof, or just by knowing what the procedure would return and in what order. The returnCode is the procedure return code (if expected), or null.
Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators