Spring business layer's personal memo to hibernate Transaction Management

Source: Internet
Author: User

<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype beans public "-// spring // DTD bean // en" "http://www.springframework.org/dtd/spring-beans.dtd">
<Beans>

<! -- Define the Transaction Manager (declarative transaction) -->
<Bean id = "transactionmanager"
Class = "org. springframework. Orm. hibernate3.hibernatetransactionmanager">
<Property name = "sessionfactory" ref = "sessionfactory"/>
</Bean>
<! -- Configure the interceptor -->
<Bean id = "transactioninterceptor"
Class = "org. springframework. transaction. Interceptor. transactioninterceptor">
<Property name = "transactionmanager" ref = "transactionmanager"/>
<! -- Configure transaction properties -->
<Property name = "transactionattributes">
<Props>
<Prop key = "*"> propagation_required </prop>
<! -- <Prop key = "insert *"> propagation_required </prop>
<Prop key = "Update *"> propagation_required </prop>
<Prop key = "delete *"> propagation_required </prop>
<Prop key = "is *"> propagation_required, redonly </prop>
<Prop key = "check *"> propagation_required, redonly </prop>
<Prop key = "get *"> propagation_required, redonly </prop>
-->
</Props>
</Property>
</Bean>
<! -- Intercept by method name -->
<Bean class = "org. springframework. AOP. Framework. autoproxy. beannameautoproxycreator">
<Property name = "beannames">
<List>
<Value> * service </value>
<Value> * manage </value>
</List>
</Property>
<Property name = "interceptornames">
<List>
<Value> transactioninterceptor </value>
</List>
</Property>
</Bean>
<! -- Configure the propagation feature of things. The following is tag control -->
<TX: Advice id = "txadvice" transaction-Manager = "transactionmanager">
<TX: Attributes>
<TX: method name = "insert *" propagation = "required"/>
<TX: method name = "Update *" propagation = "required"/>
<TX: method name = "delete *" propagation = "required"/>
<TX: method name = "is *" propagation = "required" Read-Only = "true"/>
<TX: method name = "check *" propagation = "required" Read-Only = "true"/>
<TX: method name = "get *" propagation = "required" Read-Only = "true"/>
</TX: Attributes>
</TX: Advice>
<! -- Which classes and Methods participate in things -->
<AOP: config>
<AOP: pointcut id = "interceptorpointcuts"
Expression = "execution (* cn.com. Lenovo. Role. Service. *. * (...)"/>
<AOP: Advisor advice-ref = "txadvice"
Pointcut-ref = "interceptorpointcuts"/>
</AOP: config>
</Beans>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.