Announcement Announcement Module
No announcement yet.
Problems with declarative jdbc transactions Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with declarative jdbc transactions

    Hi, i have serious problems with jdbc declarative transactions on spring i think i'm doing something wrong.

    i have this configuration on my beans.xml

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource" >
    <property name="driverClassName"><value>driver</value></property>
    <property name="url"><value>url</value></property>
    <property name="username"><value>user</value></property>
    <property name="password"><value>password</value></property>
    <bean id="resultSetExtractor" class="com.ya.isp2.kernel2.dao.ResultSetReader"/>
    <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ><ref local="dataSource"/></property>
    <bean id="ContractDAO" class="com.ya.isp2.kernel2.dao.ContractDAOTest">
    <property name="dataSource"><ref local="dataSource"></ref> </property>
    <property name="resultSetExtractor"><ref local="resultSetExtractor"></ref> </property>
    <bean id="Contract" class=" act" singleton="false" >
    <property name="dao"><ref local="ContractDAO"/></property>
    <bean id="proxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="dataSourceTransactionManager"/></property>
    <property name="target"><ref local="Contract"></ref></property>
    <property name="transactionAttributes">
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>

    but when i call the methods of the class ContractDAOTest each methods of the transaction gets a new connection and do the commit each time, and i try to force runtime exceptions at the end of the methods for doing the rollback of the transactions and the transaction has done the commit, i'm not sure what i'm doing wrong , i hope some of you could help with that.

    Another thing, i've change the configuration a lot of time in the property target of the transaction bean, i used either contract and contractdaotest, and the result is the same

    Amm, sorry for my english level , i hope you could understand me.

  • #2
    Hi, your config looks ok. How are you obtaining your Contract(DAO) bean from the BeanFactory?


    • #3
      Hi, I've realized that i was calling the bean contract, and not the bean proxy , from now on it seems that the transaction is propagated to each methods so maybe i will not have more problems. Thanks a lot