Results 1 to 4 of 4

Thread: Problem using TransactionProxyFactoryBean

  1. #1
    Join Date
    May 2005
    Posts
    2

    Default Problem using TransactionProxyFactoryBean

    I have the follwing code:

    Code:
    <bean id="txTemplateProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    	<property name="transactionManager"><ref bean="transactionManager"/></property>
    	<property name="transactionAttributes">
    		<props>
    			<prop key="insert*">PROPAGATION_NOT_SUPPORTED</prop>
    			<prop key="_insert*">PROPAGATION_REQUIRED</prop>
    		</props>
    	</property>
    </bean>
    
    <bean id="userService" parent="txTemplateProxy">
    	<property name="target">
    		<bean class="eg.UserServiceImpl"></bean>
    	</property>
    </bean>
    Code:
    public class UserServiceImpl implements UserService &#123;
    	public void insert&#40;&#41; &#123;
    		this._insert&#40;&#41;;
    		// some business logic...
    	&#125;
    
    	public void _insert&#40;&#41; &#123;
    		// some business logic...
    	&#125;
    &#125;
    My question is when I called the _insert() method from insert(), it's not in 'PROPAGATION_REQUIRED' transaction, but PROPAGATION_NOT_SUPPORTED.
    When I call it like this "context.getBean("userService")._insert();" instead of "this._insert()", it's called as 'PROPAGATION_REQUIRED'.

    What I want to do is when I called this._insert() method from same instance, I want to run other transaction without calling like "context.getBean("userService")._insert();".

    sorry my bad english.

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    I want to run other transaction without calling like "context.getBean("userService")._insert();"
    I don't think there's any non-intrusive way to do this (except try Spring's ApectJ integration). As you know, you've got to go through the proxy for the transaction advice to get applied.

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    As katentim said you have to use a proxy which means you need to get the bean from the Spring context. We had the same problem and tried to create several instances so bean A had a reference back to itself but in the form of A1 - however this prove to not be very scalable.
    You can refactor your code so the methods are in different beans which means calling a different method will spawn cross proxies.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    May 2005
    Posts
    2

    Default

    thank you for help.

    after that, I have found same issues that another guy got, too.
    http://forum.springframework.com/viewtopic.php?t=412
    http://forum.springframework.com/viewtopic.php?t=2174

    latter topic has a helpful solution for this problem.

Similar Threads

  1. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  2. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  3. Replies: 0
    Last Post: Feb 16th, 2005, 01:45 PM
  4. Oracle Jdbc invalid url problem
    By jfuchs in forum Data
    Replies: 5
    Last Post: Nov 1st, 2004, 11:33 AM
  5. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 AM

Posting Permissions

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