Announcement Announcement Module
Collapse
No announcement yet.
Q. about a Hibernate article and TransactionProxyFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Q. about a Hibernate article and TransactionProxyFactoryBean

    I cookbook quite a bit from Hibernate's "Data Access with the Spring Framework" article ( http://www.hibernate.org/110.html )

    Tonight I was working on adding transaction management to a service class and was about to use TransactionProxyFactoryBean when I re-read a line from that article:

    A convenient alternative way of setting up declarative transactions is TransactionProxyFactoryBean, particularly if there are no other AOP interceptors involved.
    Does the last part mean that I should not use this method if we plan to add other pointcuts to that service? I can back off to the previous method described, which just adds one more bean, but I haven't found anything in your docs or code that would explain why they made that statement.

    Thanks,
    -Jeff

  • #2
    A convenient alternative way of setting up declarative transactions is TransactionProxyFactoryBean, particularly if there are no other AOP interceptors
    You can add other interceptors easily enough with postInterceptors and preInterceptors properties

    Code:
        <bean id="txTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManager"/></property>
    		<property name="proxyTargetClass"><value>true</value></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="save*">PROPAGATION_REQUIRED</prop>
    				<prop key="delete*">PROPAGATION_REQUIRED</prop>
    				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="login*">PROPAGATION_REQUIRED,readOnly</prop>
    			</props>
    		</property>
    		<property name="preInterceptors">
    			<list>
    				<ref local="securityInterceptor"/>
    			</list>
    		</property>
    		<property name="postInterceptors">
    			<list>
    				<ref local="logInterceptor"/>
    			</list>
    		</property>
    	</bean>
    Does the last part mean that I should not use this method if we plan to add other pointcuts to that service?
    Do you mean other pointcuts or other interceptors?

    Comment

    Working...
    X