Results 1 to 4 of 4

Thread: How to ?

  1. #1

    Default 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
    Regards,
    S. Anand Mohan

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

    Default

    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.
    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

  3. #3

    Default Transaction demarcation to service level

    Hi mdenium,

    Quote 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.
    Regards,
    S. Anand Mohan

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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 at 04:26 PM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

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