You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by ashok <as...@sraindia.com> on 2007/06/29 09:52:44 UTC

Global Transactions or Ibatis's Automatic transactions

Hi

Does the daoManger.startTransaction(); created refers to the Global 
transactions or Ibatis  Automatic transactions?
What changes to be made if I need to use global transactions?

In my  DaoIntializer class  I create the daoManager as follows :

Reader reader = Resources.getResourceAsReader("com/example/config/dao.xml");
            daoManager = DaoManagerBuilder.buildDaoManager(reader);

and  dao.xml, sqlMapConfig.xml and web.xml contains the following enteries:

In my dao.xml :
<daoConfig>
    <context>
        <transactionManager type="SQLMAP">
            <property name="SqlMapConfigResource"
                value="com/example/config/sqlMapConfig.xml" />
        </transactionManager>

        <dao interface="com.example.ibatis.UserTableDao"
            implementation="com.example.ibatis.UserTableDaoImpl" />
    </context>
</daoConfig>

In my sqlMapConfig.xml

<sqlMapConfig>

    <settings cacheModelsEnabled="true" enhancementEnabled="true"
        lazyLoadingEnabled="true" errorTracingEnabled="false" 
maxRequests="32"
        maxSessions="10" maxTransactions="5" 
useStatementNamespaces="false" />

    <transactionManager type="EXTERNAL">
     <property name="UserTransaction" 
value="java:comp/env/UserTransaction"/>
      <property name="SetAutoCommitAllowed" value="false"/>
        <dataSource type="JNDI">
        <property name="DataSource" value="java:comp/env/jdbc/exampleDB" />
        </dataSource>
 
   <sqlMap resource="com/example/ibatis/sqlMap/UserTable.xml" />
</sqlMapConfig>



In my web.xml :

    <resource-ref>
        <description>Example DBConnection</description>
        <res-ref-name>jdbc/exampleDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <resource-ref>
        <description>Example Transaction Manger</description>
        <res-ref-name>UserTransaction</res-ref-name>
        <res-type>javax.transaction.UserTransaction</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>



















Regards
Ashok


Re: Global Transactions or Ibatis's Automatic transactions

Posted by Jeff Butler <je...@gmail.com>.
When using EXTERNAL transactions, the startTransaction() method does
nothing.  So JTA's transaction is not being called either - EXTERNAL means
that iBATIS is completely trusting some external source to manage
transactions (like an EJB container).

If you want to control JTA from withing iBATIS, use the JTA transaction
manager.

Jeff Butler


On 6/29/07, ashok <as...@sraindia.com> wrote:
>
>
> I am trying to add Ibatis persistence to struts , cannot use springs.
> When daoManager.startTransaction();  how can we ensure that the JTA's
> transaction is being called and not the Ibatis Automatic transactions.
>
>
> Meindert wrote:
> > Ibatis DAO has been depreciated.. Use spring instead
> >
> > -----Original Message-----
> > From: ashok [mailto:ashok@sraindia.com]
> > Sent: 29 June 2007 09:53 AM
> > To: ibatis
> > Subject: Global Transactions or Ibatis's Automatic transactions
> >
> > Hi
> >
> > Does the daoManger.startTransaction(); created refers to the Global
> > transactions or Ibatis  Automatic transactions?
> > What changes to be made if I need to use global transactions?
> >
> > In my  DaoIntializer class  I create the daoManager as follows :
> >
> > Reader reader = Resources.getResourceAsReader
> ("com/example/config/dao.xml");
> >             daoManager = DaoManagerBuilder.buildDaoManager(reader);
> >
> > and  dao.xml, sqlMapConfig.xml and web.xml contains the following
> enteries:
> >
> > In my dao.xml :
> > <daoConfig>
> >     <context>
> >         <transactionManager type="SQLMAP">
> >             <property name="SqlMapConfigResource"
> >                 value="com/example/config/sqlMapConfig.xml" />
> >         </transactionManager>
> >
> >         <dao interface="com.example.ibatis.UserTableDao"
> >             implementation="com.example.ibatis.UserTableDaoImpl" />
> >     </context>
> > </daoConfig>
> >
> > In my sqlMapConfig.xml
> >
> > <sqlMapConfig>
> >
> >     <settings cacheModelsEnabled="true" enhancementEnabled="true"
> >         lazyLoadingEnabled="true" errorTracingEnabled="false"
> > maxRequests="32"
> >         maxSessions="10" maxTransactions="5"
> > useStatementNamespaces="false" />
> >
> >     <transactionManager type="EXTERNAL">
> >      <property name="UserTransaction"
> > value="java:comp/env/UserTransaction"/>
> >       <property name="SetAutoCommitAllowed" value="false"/>
> >         <dataSource type="JNDI">
> >         <property name="DataSource" value="java:comp/env/jdbc/exampleDB"
> />
> >         </dataSource>
> >
> >    <sqlMap resource="com/example/ibatis/sqlMap/UserTable.xml" />
> > </sqlMapConfig>
> >
> >
> >
> > In my web.xml :
> >
> >     <resource-ref>
> >         <description>Example DBConnection</description>
> >         <res-ref-name>jdbc/exampleDB</res-ref-name>
> >         <res-type>javax.sql.DataSource</res-type>
> >         <res-auth>Container</res-auth>
> >     </resource-ref>
> >
> >     <resource-ref>
> >         <description>Example Transaction Manger</description>
> >         <res-ref-name>UserTransaction</res-ref-name>
> >         <res-type>javax.transaction.UserTransaction</res-type>
> >         <res-auth>Container</res-auth>
> >     </resource-ref>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Regards
> > Ashok
> >
> >
>
>
>

RE: Global Transactions or Ibatis's Automatic transactions

Posted by "Hemant.Kamatgi" <He...@target.com>.
Ashok,

I had mentioned the JNDI name of the directly in the  sqlmapconfig.xml
viz, jdbc/exampleDB (I mean not the reference like
java:comp/env/jdbc/exampleDB) and transactionmanager type was
'EXTERNAL'. Plus we were starting our transaction in our business layer
and not in the DAO layer. We have used both BMT(UserTransaction)and CMT
to start and end transactions and it has worked quite well.

Regards
Hemant

-----Original Message-----
From: ashok [mailto:ashok@sraindia.com] 
Sent: Friday, June 29, 2007 4:00 AM
To: user-java@ibatis.apache.org
Subject: Re: Global Transactions or Ibatis's Automatic transactions


I am trying to add Ibatis persistence to struts , cannot use springs.
When daoManager.startTransaction();  how can we ensure that the JTA's
transaction is being called and not the Ibatis Automatic transactions.


Meindert wrote:
> Ibatis DAO has been depreciated.. Use spring instead
>
> -----Original Message-----
> From: ashok [mailto:ashok@sraindia.com] 
> Sent: 29 June 2007 09:53 AM
> To: ibatis
> Subject: Global Transactions or Ibatis's Automatic transactions
>
> Hi
>
> Does the daoManger.startTransaction(); created refers to the Global 
> transactions or Ibatis  Automatic transactions?
> What changes to be made if I need to use global transactions?
>
> In my  DaoIntializer class  I create the daoManager as follows :
>
> Reader reader =
Resources.getResourceAsReader("com/example/config/dao.xml");
>             daoManager = DaoManagerBuilder.buildDaoManager(reader);
>
> and  dao.xml, sqlMapConfig.xml and web.xml contains the following
enteries:
>
> In my dao.xml :
> <daoConfig>
>     <context>
>         <transactionManager type="SQLMAP">
>             <property name="SqlMapConfigResource"
>                 value="com/example/config/sqlMapConfig.xml" />
>         </transactionManager>
>
>         <dao interface="com.example.ibatis.UserTableDao"
>             implementation="com.example.ibatis.UserTableDaoImpl" />
>     </context>
> </daoConfig>
>
> In my sqlMapConfig.xml
>
> <sqlMapConfig>
>
>     <settings cacheModelsEnabled="true" enhancementEnabled="true"
>         lazyLoadingEnabled="true" errorTracingEnabled="false" 
> maxRequests="32"
>         maxSessions="10" maxTransactions="5" 
> useStatementNamespaces="false" />
>
>     <transactionManager type="EXTERNAL">
>      <property name="UserTransaction" 
> value="java:comp/env/UserTransaction"/>
>       <property name="SetAutoCommitAllowed" value="false"/>
>         <dataSource type="JNDI">
>         <property name="DataSource"
value="java:comp/env/jdbc/exampleDB" />
>         </dataSource>
>  
>    <sqlMap resource="com/example/ibatis/sqlMap/UserTable.xml" />
> </sqlMapConfig>
>
>
>
> In my web.xml :
>
>     <resource-ref>
>         <description>Example DBConnection</description>
>         <res-ref-name>jdbc/exampleDB</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
>
>     <resource-ref>
>         <description>Example Transaction Manger</description>
>         <res-ref-name>UserTransaction</res-ref-name>
>         <res-type>javax.transaction.UserTransaction</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Regards
> Ashok
>
>   

Re: Global Transactions or Ibatis's Automatic transactions

Posted by ashok <as...@sraindia.com>.
I am trying to add Ibatis persistence to struts , cannot use springs.
When daoManager.startTransaction();  how can we ensure that the JTA's 
transaction is being called and not the Ibatis Automatic transactions.


Meindert wrote:
> Ibatis DAO has been depreciated.. Use spring instead
>
> -----Original Message-----
> From: ashok [mailto:ashok@sraindia.com] 
> Sent: 29 June 2007 09:53 AM
> To: ibatis
> Subject: Global Transactions or Ibatis's Automatic transactions
>
> Hi
>
> Does the daoManger.startTransaction(); created refers to the Global 
> transactions or Ibatis  Automatic transactions?
> What changes to be made if I need to use global transactions?
>
> In my  DaoIntializer class  I create the daoManager as follows :
>
> Reader reader = Resources.getResourceAsReader("com/example/config/dao.xml");
>             daoManager = DaoManagerBuilder.buildDaoManager(reader);
>
> and  dao.xml, sqlMapConfig.xml and web.xml contains the following enteries:
>
> In my dao.xml :
> <daoConfig>
>     <context>
>         <transactionManager type="SQLMAP">
>             <property name="SqlMapConfigResource"
>                 value="com/example/config/sqlMapConfig.xml" />
>         </transactionManager>
>
>         <dao interface="com.example.ibatis.UserTableDao"
>             implementation="com.example.ibatis.UserTableDaoImpl" />
>     </context>
> </daoConfig>
>
> In my sqlMapConfig.xml
>
> <sqlMapConfig>
>
>     <settings cacheModelsEnabled="true" enhancementEnabled="true"
>         lazyLoadingEnabled="true" errorTracingEnabled="false" 
> maxRequests="32"
>         maxSessions="10" maxTransactions="5" 
> useStatementNamespaces="false" />
>
>     <transactionManager type="EXTERNAL">
>      <property name="UserTransaction" 
> value="java:comp/env/UserTransaction"/>
>       <property name="SetAutoCommitAllowed" value="false"/>
>         <dataSource type="JNDI">
>         <property name="DataSource" value="java:comp/env/jdbc/exampleDB" />
>         </dataSource>
>  
>    <sqlMap resource="com/example/ibatis/sqlMap/UserTable.xml" />
> </sqlMapConfig>
>
>
>
> In my web.xml :
>
>     <resource-ref>
>         <description>Example DBConnection</description>
>         <res-ref-name>jdbc/exampleDB</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
>
>     <resource-ref>
>         <description>Example Transaction Manger</description>
>         <res-ref-name>UserTransaction</res-ref-name>
>         <res-type>javax.transaction.UserTransaction</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Regards
> Ashok
>
>   



RE: Global Transactions or Ibatis's Automatic transactions

Posted by Meindert <me...@pastelebusiness.com>.
Ibatis DAO has been depreciated.. Use spring instead

-----Original Message-----
From: ashok [mailto:ashok@sraindia.com] 
Sent: 29 June 2007 09:53 AM
To: ibatis
Subject: Global Transactions or Ibatis's Automatic transactions

Hi

Does the daoManger.startTransaction(); created refers to the Global 
transactions or Ibatis  Automatic transactions?
What changes to be made if I need to use global transactions?

In my  DaoIntializer class  I create the daoManager as follows :

Reader reader = Resources.getResourceAsReader("com/example/config/dao.xml");
            daoManager = DaoManagerBuilder.buildDaoManager(reader);

and  dao.xml, sqlMapConfig.xml and web.xml contains the following enteries:

In my dao.xml :
<daoConfig>
    <context>
        <transactionManager type="SQLMAP">
            <property name="SqlMapConfigResource"
                value="com/example/config/sqlMapConfig.xml" />
        </transactionManager>

        <dao interface="com.example.ibatis.UserTableDao"
            implementation="com.example.ibatis.UserTableDaoImpl" />
    </context>
</daoConfig>

In my sqlMapConfig.xml

<sqlMapConfig>

    <settings cacheModelsEnabled="true" enhancementEnabled="true"
        lazyLoadingEnabled="true" errorTracingEnabled="false" 
maxRequests="32"
        maxSessions="10" maxTransactions="5" 
useStatementNamespaces="false" />

    <transactionManager type="EXTERNAL">
     <property name="UserTransaction" 
value="java:comp/env/UserTransaction"/>
      <property name="SetAutoCommitAllowed" value="false"/>
        <dataSource type="JNDI">
        <property name="DataSource" value="java:comp/env/jdbc/exampleDB" />
        </dataSource>
 
   <sqlMap resource="com/example/ibatis/sqlMap/UserTable.xml" />
</sqlMapConfig>



In my web.xml :

    <resource-ref>
        <description>Example DBConnection</description>
        <res-ref-name>jdbc/exampleDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <resource-ref>
        <description>Example Transaction Manger</description>
        <res-ref-name>UserTransaction</res-ref-name>
        <res-type>javax.transaction.UserTransaction</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>



















Regards
Ashok