Results 1 to 2 of 2

Thread: Transaction Setup for Ibatis/HSQLDB

  1. #1
    Join Date
    May 2005
    Posts
    6

    Default Transaction Setup for Ibatis/HSQLDB

    Hello Everyone!

    We are building a data model using Spring DAO, and this model is based on the Petclinic sample application in Spring 1.1.5 (ibatis flavor).

    Everything is working. But I'm wondering about transactions, and what I have to do to set them up correctly. Here is our datasource/txn manager configuration:

    <beans>
    <bean id="dataSource" class="com.ibatis.common.jdbc.SimpleDataSource">
    <constructor-arg>
    <map>
    <entry key="JDBC.Driver"><value>org.hsqldb.jdbcDriver</value></entry>
    <entry key="JDBC.ConnectionURL"><value>jdbc:hsqldb:hsql://10.250.1.23</value></entry>
    <entry key="JDBC.Username"><value>sa</value></entry>
    <entry key="JDBC.Password"><value></value></entry>
    <entry key="JDBC.DefaultAutoCommit"><value>true</value></entry>
    </map>
    </constructor-arg>
    </bean>

    <!-- Transaction manager for a single JDBC DataSource -->
    <!-- (see dataAccessContext-jta.xml for an alternative) -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <!-- SqlMap setup for iBATIS Database Layer -->
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
    <property name="configLocation"><value>conf/sql-map-config.xml</value></property>
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    Does this current arrangement provide transactions or not? Or do I need to set up a transaction proxy and specify which methods actually get transactions? How can I tell whether transactions are actually being used?

    Please advise.

    Thanks in advance,
    craig vanderborgh
    voxware incorporated

  2. #2
    Join Date
    May 2005
    Posts
    208

    Default

    Quote Originally Posted by bincbom
    Hello Everyone!

    We are building a data model using Spring DAO, and this model is based on the Petclinic sample application in Spring 1.1.5 (ibatis flavor).

    Everything is working. But I'm wondering about transactions, and what I have to do to set them up correctly. Here is our datasource/txn manager configuration:

    <beans>
    <bean id="dataSource" class="com.ibatis.common.jdbc.SimpleDataSource">
    <constructor-arg>
    <map>
    <entry key="JDBC.Driver"><value>org.hsqldb.jdbcDriver</value></entry>
    <entry key="JDBC.ConnectionURL"><value>jdbc:hsqldb:hsql://10.250.1.23</value></entry>
    <entry key="JDBC.Username"><value>sa</value></entry>
    <entry key="JDBC.Password"><value></value></entry>
    <entry key="JDBC.DefaultAutoCommit"><value>true</value></entry>
    </map>
    </constructor-arg>
    </bean>

    <!-- Transaction manager for a single JDBC DataSource -->
    <!-- (see dataAccessContext-jta.xml for an alternative) -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    <!-- SqlMap setup for iBATIS Database Layer -->
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
    <property name="configLocation"><value>conf/sql-map-config.xml</value></property>
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

    Does this current arrangement provide transactions or not? Or do I need to set up a transaction proxy and specify which methods actually get transactions? How can I tell whether transactions are actually being used?

    Please advise.

    Thanks in advance,
    craig vanderborgh
    voxware incorporated

    Hi Craig,

    I think you have to set up a transaction proxy and specify the propagation requirements. You'll need more stuff in your context XML. These should not be on the DAO classes themselves, rather on the service classes that use the DAOs.

    If you're unit testing DAOs, there's no need for the transaction proxy. I had a recent thread in the Data Access forum that details my struggles in excrutiating detail.

    You can tell they're being used if you turn on logging at the DEBUG level. You'll see the rollbacks and commits that way.

    %

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •