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 Ralf Assmann <ra...@innovations.de> on 2007/05/24 14:23:27 UTC

Defining Transaction Isolation Using iBATIS

Hi there,

is it possible to set the transaction isolation level for all 
connections using an entry in sqlMapConfig.xml, such as settings for 
auto commit etc.? If yes, what does the parameter look like?

We want to get all connections having the same transaction isolation in 
the application, without calling methods to set this level manually. The 
current behaviour depends on the kind of database, sqlserver has an 
other default value than db2 etc.

Many thanks.

Ralf


-------------------------------------------------------------------
Ralf Assmann, Dipl.-Ing. (FH)
Innovations Softwaretechnologie GmbH
Ziegelei 7, 88090 Immenstaad, Germany
Tel.: +49 7545 202-324
Tel.: +49 7545 202-300 (Zentrale)
Fax.: +49 7545 202-301
Email: ralf.assmann@innovations.de
Web: http://www.innovations.de
-------------------------------------------------------------------
Geschaeftsfuehrung: 
Achim Berger, Thomas Cotic, Walter Pitz
Reg.-Gericht Ulm HRB 631622
-------------------------------------------------------------------



Re: Defining Transaction Isolation Using iBATIS

Posted by Ralf Assmann <ra...@innovations.de>.
Hi,

thanks for your answer.

Unfortunately, is does not help. We do not use Spring in this 
application, only iBATIS as "standalone" ...

Regards,

Ralf

-------------------------------------------------------------------
Ralf Assmann, Dipl.-Ing. (FH)
Innovations Softwaretechnologie GmbH
Ziegelei 7, 88090 Immenstaad, Germany
Tel.: +49 7545 202-324
Tel.: +49 7545 202-300 (Zentrale)
Fax.: +49 7545 202-301
Email: ralf.assmann@innovations.de
Web: http://www.innovations.de
-------------------------------------------------------------------
Geschaeftsfuehrung: 
Achim Berger, Thomas Cotic, Walter Pitz
Reg.-Gericht Ulm HRB 631622
-------------------------------------------------------------------




Meindert schrieb:
>
> Hi Ralf,
>
> Not sure if it will answer your question but the Ibatis ADO framework 
> has been depreciated.
>
> We wrote a little piece in the Wiki how to convert jpetstore to the 
> Spring ADO framework,
>
> You will set the transaction isolation in the Spring configuration 
> files (or by annotation)
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/Converting+iBATIS+DAO+to+Spring+DAO
>
> This wiki is missing the changes to make for the transactions;
>
> 1) Add cglib-nodep-2.1_3.jar to the classpath
>
> *2) OrderService.java*
>
> Add the annotation for spring to implement transactions, meaning
>
> at @Transactional just above the insertOrder method
>
> at @Transactional(readOnly=true)just above the getOrder method
>
> Add a empty constructor;
>
> public OrderService() {
>
> }
>
> 3) Spring config
>
> Add the following to the spring config file;
>
> <!-- TRANSACTIONS -->
>
> <bean id="txManager" 
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>
> <property name="dataSource">
>
> <ref bean="dataSource"/>
>
> </property>
>
> </bean>
>
> <bean 
> class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
>
> <bean 
> class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
>
> <property name="transactionInterceptor" ref="txInterceptor"/>
>
> </bean>
>
> <bean id="txInterceptor" 
> class="org.springframework.transaction.interceptor.TransactionInterceptor">
>
> <property name="transactionManager" ref="txManager"/>
>
> <property name="transactionAttributeSource">
>
> <bean 
> class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
>
> </property>
>
> </bean>
>
> I didn’t try but, tom told me that you can simplify this to:
>
> /<bean id="txManager" 
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">// 
> /
>
> /<property name="dataSource">///
>
> /<ref bean="dataSource"/>///
>
> /</property>///
>
> /</bean>///
>
> / /
>
> /followed by:/
>
> / /
>
> /<tx:annotation-driven transaction-manager="txManager"/>/
>
> / /
>
> /You can even get rid of the transaction-manager="txManager" part if 
> you rename your DataSourceTransactionManager bean to 
> "transactionManager," e.g.,/
>
> / /
>
> /<bean id="transactionManager" 
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">/
>
> /.../
>
> /</bean>/
>
> / /
>
> /See: http://tinyurl.com/yqncrj/
>
> / /
>
> /Tom/
>
> -----Original Message-----
>

RE: Defining Transaction Isolation Using iBATIS

Posted by Meindert <me...@pastelebusiness.com>.
Hi Ralf,

 

Not sure if it will answer your question but the Ibatis ADO framework has
been depreciated.

 

We wrote a little piece in the Wiki how to convert jpetstore to the Spring
ADO framework, 

You will set the transaction isolation in the Spring configuration files (or
by annotation)

 

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Converting+iBA
TIS+DAO+to+Spring+DAO

 

This wiki is missing the changes to make for the transactions;

 

1) Add cglib-nodep-2.1_3.jar to the classpath

 

2) OrderService.java

Add the annotation for spring to implement transactions, meaning 

at @Transactional just above the insertOrder method

at @Transactional(readOnly=true)just above the getOrder method

Add a empty constructor;

public OrderService() {

}

 

3) Spring config

Add the following to the spring config file;

<!-- TRANSACTIONS -->

    <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource">

            <ref bean="dataSource"/>

        </property>

    </bean>

    

    <bean
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCr
eator"/>

    

    <bean
class="org.springframework.transaction.interceptor.TransactionAttributeSourc
eAdvisor">

        <property name="transactionInterceptor" ref="txInterceptor"/>

    </bean>

    

    <bean id="txInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">

        <property name="transactionManager" ref="txManager"/>

        <property name="transactionAttributeSource">

            <bean
class="org.springframework.transaction.annotation.AnnotationTransactionAttri
buteSource"/>

        </property>

    </bean>

I didn't try but, tom told me that you can simplify this to: 

 

<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 

<property name="dataSource">

<ref bean="dataSource"/>

</property>

</bean>

 

followed by:

 

<tx:annotation-driven transaction-manager="txManager"/>

 

You can even get rid of the transaction-manager="txManager" part if you
rename your DataSourceTransactionManager bean to "transactionManager," e.g.,

 

<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

...

</bean>

 

See: http://tinyurl.com/yqncrj

 

Tom

 

 

 

-----Original Message-----