Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Transaction problems

  1. #11
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    The key is whatever is being Proxied needs to implement some interface. You don't need to proxy the DAO, or even have the DAO use an interface (although its advisable for testing purposes) if you are using another class to call several operations from the DAO. For example:

    Code:
    public interface DocManager {
      public void doStuff();
    }
    
    public class DocManagerImpl {
      private MyDao dao;
      public void setDocDao(DocDao dao) {
        this.dao = dao;
      }
      public void doStuff() {
        dao.call1();
        dao.call2();
        dao.call3();
      }
    }
    To wire it up:

    Code:
    <bean id="docManager" class="DocManagerImpl>
      <property name="docDao" ref="docDao"/>
    </bean>
    
    <bean id="docDao" class="">
      <property name="dataSource"><ref local="dataSource"/></property>
    </bean>
    
    <bean id="docProxy" 
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> 
      <property name="transactionManager"><ref bean="transactionManager"/></property> 
      <property name="target"><ref bean="docManager"/></property> 
      <property name="transactionAttributes"> 
        <props> 
          <prop key="*">PROPAGATION_REQUIRED,-DataAccessException,-SQLException</prop> 
        </props> 
      </property> 
    </bean>
    Bill

  2. #12

    Default

    Thanks for all your help!! It took me the entire day yesterday but the trx's are working now.

Posting Permissions

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