If I'm not mistaken, if you're using transaction management within the
stored proc, you have to ensure that the DB connection is set to
autocommit.  iBATIS doesn't allow autocommit within its own transaction
manager, so you'll need to manage your own connection using
openSession(Connection)/closeSession().

Clinton

On 3/21/07, shailesh.sutar <[EMAIL PROTECTED]> wrote:


I am using stored procedure for DB related stuff using iBATIS. (SQL server
2000).When i call procedure in which i do some DB updation stuff, it works
fine.
ie.
Code:
sqlMapClient.startTransaction();
sqlMapClient.queryForObject("changeMerchantDetails", map);
sqlMapClient.commitTransaction();
sqlMapClient.endTransaction();

But if i use transaction management inside stored procedure using BEGIN
TRAN
---- END TRAN, there is problem.
ie. I am just calling
sqlMapClient.queryForObject("changeMerchantDetails ", map);
because there is BEGIN TRAN-----END TRAN inside stored procedure.

Procedure get called but there is no updation in DB.
(I am checking OUTPUT param values after calling procedure to check if
procedure gets called or not)

If i want to use transaction management inside stored procedure using
BEGIN
TRAN ---- END TRAN, how can i do it using iBATIS.

My sqlmapconfig.xml file is
Code:
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig   PUBLIC "-//ibatis.apache.org//DTD SQL Map Config
2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd";>

<sqlMapConfig>


  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
     <property name="JDBC.Driver"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<property name="JDBC.ConnectionURL"

value="jdbc:microsoft:sqlserver://192.168.2.22:2222;databaseName=dbname;SelectMethod=cursor"/>
        <property name="JDBC.Username" value="usr"/>
        <property name="JDBC.Password" value="pwd"/>

        <property name="Pool.MaximumActiveConnections" value="10"/>
        <property name="Pool.MaximumIdleConnections" value="5"/>
        <property name="Pool.MaximumCheckoutTime" value="120000"/>
        <property name="Pool.TimeToWait" value="10000"/>
    </dataSource>
  </transactionManager>

  <!-- List the SQL Map XML files. They can be loaded from the
       classpath, as they are here (com.domain.data...) -->
  <sqlMap resource="Account.xml"/>


</sqlMapConfig>

Account.xml file is
Code:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-2.dtd";>
<sqlMap namespace="Account">

<parameterMap id="merchantDetails" class="map" >
<parameter property="salutation" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN"/>
<parameter property="first_name" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN"/>
<parameter property="middle_name" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN"/>
<parameter property="last_name" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN"/>
<parameter property="errstatus" jdbcType="VARCHAR"
javaType="java.lang.String" mode="OUT"/>
</parameterMap>

<procedure id="changeMerchantDetails" parameterMap="merchantDetails" >
{call PG_upd_user_details(?,?,?,?,?) }
</procedure>

</sqlMap>

I want to know how to use iBatis for SQL server's BEGIN TRAN ---- END TRAN
inside stored procedure.
Is there any extra configuration required in sqlmapconfig file?
--
View this message in context:
http://www.nabble.com/Problem-using-iBatis-and-transaction-management-inside-Stored-procedure-tf3438925.html#a9588734
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Reply via email to