Results 1 to 2 of 2

Thread: Problem with Rollback on Tests

  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Default Problem with Rollback on Tests

    Hello,
    I am having some issues with my spring context integration tests. I have gotten them all wired up loading the context correctly; however, when they run they do not rollback the transaction that the test is executed within (well--actually the logs SAY that the tran rolled back, but the data is still present within the DB). My base testing class extends from AbstractTransactionalDataSourceSpringContextTests. The strange thing is that I can debug it and see it starting a transaction within Spring and rolling back the transaction as well. Here is the output of whats happening:

    [Date: 2009-06-09 09:20:48,906] DEBUG [main] ProcessorDaoTest.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.jdbc.datasource.DataSourceTran sactionManager@6173b]; rollback [true].
    [Date: 2009-06-09 09:20:48,938] DEBUG [main] ProcessorDaoTest.endTransaction(360) | Rolled back transaction after execution of test [testFindAvailableProcessors].

    And here is my spring configuration:

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

    <!-- a PlatformTransactionManager is still required -->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <!-- (this dependency is defined somewhere else) -->
    <property name="dataSource" ref="dataSource"/>
    </bean>


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://127.0.0.1/somedatabase?useUnicode=true&amp;amp;characterEnco ding=utf-8" />
    <property name="username" value="root" />
    <property name="password" value="root" />
    <property name="maxActive" value="100"/>
    <property name="maxIdle" value="30"/>
    <property name="maxWait" value="1000"/>
    <property name="defaultAutoCommit" value="false"/>
    <property name="removeAbandoned" value="true"/>
    <property name="removeAbandonedTimeout" value="60"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    </props>
    </property>
    <property name="annotatedClasses">
    <list>
    <value>com.eltechnologies.feedmixup.processor.mode l.impl.Processor</value>
    </list>
    </property>
    </bean>

    I am using the following for my libraries:
    spring-test -- v2.5.6
    commons-dbcp -- v1.2.2

    Does anyone have an idea of where I am going wrong with this? I'm sure its some sort of library or configuration issue, but can't seem to figure it out. Thanks so much for all the help!

    -Eric

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    When posting code please use [ code][/code ] tags.

    1) Use the correct TransactionManager (You use Hibernate so use HibernateTransactionManager!)
    2) You are using MySQL make sure that you use a table type that supports transactions (InnoDB)
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

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