Announcement Announcement Module
Collapse
No announcement yet.
How to ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to ?

    Hi Friends,


    Ihave three methods which has to be called in one transaction from three different DAO's


    method 1 addUsers() from UsersDaoImpl
    method 2 addUserNgroups() from UserNGroupDaoImpl
    method 3 addUserNRole() from UserNRoleDaiImpl

    Thje transaction management is as follows for UsersDaoImpl.
    Code:
    	<!-- dceUserDAO config starts here  -->
    	<bean id="dceUserDAO"
    		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref bean="transactionManager" />
    		</property>
    		<property name="target">
    			<ref bean="dceUserDAOTarget" />
    		</property>
    		<property name="transactionAttributes">
    			<!-- define the transaction specs here -->
    			<props>
    				<prop key="addGroupSafe">PROPAGATION_REQUIRED</prop>
    
    			</props>
    		</property>
    	</bean>
    	<bean id="dceUserDAOTarget"
    		class="com.nucleus.dce.dao.hibernate.DceUsersDAOImpl">
    		<property name="sessionFactory">
    			<ref bean="sessionFactory" />
    		</property>
    	</bean>
    Similarli the other two DAO's are configured seperately

    Plz help in this regard

    Thanks & Regards,
    S.Anand mohan

  • #2
    Normally you want to define your transactions on the Service layer and not on yuor database layer. that way your business method is transactional. So pull-up your transaction demarcation one level from dao to service.

    Comment


    • #3
      Transaction demarcation to service level

      Hi mdenium,

      Originally posted by mdeinum View Post
      Normally you want to define your transactions on the Service layer and not on yuor database layer. that way your business method is transactional. So pull-up your transaction demarcation one level from dao to service.
      Plz guide me, whether I am in the right track or not..

      suppose I have a bean RegistrationController.java of the service layer, in which I am calling the three methods then I have to configure
      Code:
      	<bean id="regController"
      		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      		<property name="transactionManager">
      			<ref bean="transactionManager" />
      		</property>
      		<property name="target">
      			<ref bean="regControllerTarget" />
      		</property>
      		<property name="transactionAttributes">
      			<!-- define the transaction specs here -->
      			<props>
      				<prop key="addGroupSafe">PROPAGATION_REQUIRED</prop>
      
      			</props>
      		</property>
      	</bean>
      	<bean id="regControllerTarget"
      		class="MyPackage.RegistrationController">
      		<property name="sessionFactory">
      			<ref bean="sessionFactory" />
      		</property>
      	</bean>
      Thanks & Regards,
      S. Anand Mohan.

      Comment


      • #4
        Yes that should work, one reservation is that if this controller is a MVC style one you might have problems. Where is the controller called from?
        http://www.martinfowler.com/eaaCatal...viceLayer.html
        http://www.springframework.org/docs/...decl-explained
        Last edited by karldmoore; Aug 27th, 2007, 05:26 PM.

        Comment

        Working...
        X