Results 1 to 3 of 3

Thread: TransactionProxyFactoryBean with non-Spring supplied target?

  1. #1
    Join Date
    Aug 2004
    Location
    berkeley, ca, usa
    Posts
    13

    Default TransactionProxyFactoryBean with non-Spring supplied target?

    I would like to use the declarative transaction management abililities of TransactionProxyFactoryBean in conjunction with JTATransactionManager and JOTM.

    My problem is that I can't wire-up the target on TransactionProxyFactoryBean, because the object that is to be proxied is supplied by Hibernate (recreated from database), and so isn't defined in my applicationContext.xml configuration file. As I understand it, the tx proxy factory bean only proxies the object that it is wired to in the configuration file.

    I tried manually getting the factory bean and setting the target programmatically, but there was a startup error saying that target was not set.

    This is what I have in my applicationContext.xml file so far:

    Code:
    <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>
    <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    	<property name="userTransaction">
    		<ref local="jotm"/>
    	</property>
    </bean>
    <bean id="xaDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource"
    	singleton="false" destroy-method="shutdown">
    	<property name="transactionManager">
    		<ref local="jotm"/>
    	</property>
    </bean>
    <bean id="xaPoolDataSource"
    	class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
    	destroy-method="shutdown" singleton="false">
    	<property name="dataSource">
    		<ref local="xaDataSource"/>
    	</property>
    </bean>
    <bean id="jtaTransactionProxy"
    	class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
    	<property name="transactionManager">
    		<ref local="jtaTransactionManager"/>
    	</property>
    	<property name="transactionAttributes">
    		<props>
    			<!-- write actions&#58; rollback if any exception occurs -->
    			<prop key="execute*">PROPAGATION_REQUIRED,-Exception</prop>
    		</props>
    	</property>
    	<property name="target">
    		<bean id="quartzJob" class="com.thatone.archie.engine.job.QuartzJobImpl" singleton="false"/>
    	</property>
    </bean>
    Any help or pointers to resources that might be helpful would be really appreciated.

    thanks...

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    I'm not sure it's good usage, but you could define a transactional prototype bean and configure Hibernate to get a prototype instance from the current application context instance of using new when creating a new object. I can't remember the details of how to do this with Hibernate, but I know some users do use DI on Hibernate-managed instances this way.

    There will be a performance overhead compared to using new, but you should be OK unless you're retrieving large numbers of objects.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Location
    Brooklyn, NY
    Posts
    20

    Default

    Quote Originally Posted by Rod Johnson
    I'm not sure it's good usage, but you could define a transactional prototype bean and configure Hibernate to get a prototype instance from the current application context instance of using new when creating a new object. I can't remember the details of how to do this with Hibernate, but I know some users do use DI on Hibernate-managed instances this way.

    There will be a performance overhead compared to using new, but you should be OK unless you're retrieving large numbers of objects.
    Any more leads on where to do this? We're facing a similar issue. Is this transactional prototype bean something we would create based on a Hibernate class or a Spring class?

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. Gaijin Studio for Spring MVC 0.9.2 Released
    By dadams in forum Announcements
    Replies: 8
    Last Post: May 30th, 2007, 10:48 PM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

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