Transactionproxyfactorybean function and configuration in spring (RPM)

Source: Internet
Author: User
Tags knowledge base

Ask:

Original link http://blog.csdn.net/cpp_lzth/article/details/6551703

When we look at AOP, we find that there is a org.springframework.transaction.interceptor.TransactionProxyFactoryBean in spring. And why is this class configured here???

For:

[XHTML]View PlainCopy
  1. <!--setting up data sources-
  2. <Bean id= "DataSource" class= "Org.springframework.jndi.JndiObjectFactoryBean">
  3. <property name= "Jndiname">
  4. <value> <a href= "http://lib.csdn.net/base/ Javase " class= ' Replace_word '   title= "Java se Knowledge Base"   Target= ' _blank '  style= ' color: #df3434; font-weight:bold; ' >java</a>:comp/env/jdbc/ Ayoa </value>      
  5. </Property>
  6. </Bean>
  7. <!--settings Ibatis--
  8. <Bean id= " sqlmapclient" class= "Org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
  9. <property name= "configlocation">
  10. <value> Classpath:com/ayoa/bean/sqlmapdao/sql-map-config.xml </value>
  11. </Property>
  12. <property name= "DataSource">
  13. <ref bean= "DataSource"/>
  14. </Property>
  15. </Bean>
  16. <!--set up transaction management--
  17. <Bean id= " transactionmanager" class= " Org.springframework.jdbc.datasource.DataSourceTransactionManager ">
  18. <property name= "DataSource">
  19. <ref bean= "DataSource"/>
  20. </Property>
  21. </Bean>
  22. <!--set DAO--
  23. <Bean id= " Vssdao" class= " Com.wehave.hyerp.productmanage.persistence.sqlmapdao.VssSqlMapDao ">
  24. <property name= "sqlmapclient">
  25. <ref bean= "sqlmapclient"/>
  26. </Property>
  27. </Bean>
  28. <!--business layer to spring for transaction management--
  29. <Bean id= " vssservice" class= " Org.springframework.transaction.interceptor.TransactionProxyFactoryBean ">
  30. <property name= "TransactionManager">
  31. <ref bean= "TransactionManager"> </ref>
  32. </Property>
  33. <property name= "target">
  34. <Bean class= "Com.wehave.hyerp.productmanage.service.VssService">
  35. <property name= "Vssdao">
  36. <ref bean= "Vssdao"/>
  37. </Property>
  38. </Bean>
  39. </Property>
  40. <property name= "transactionattributes">
  41. <props>
  42. <prop key= "Insertvss"> propagation_required </prop>
  43. </props>
  44. </Property>
  45. </Bean>

Ask:

What's the difference between giving the DAO to the control layer directly???

Why use Transactionproxyfactorybean to cover DAO???

Transactionproxyfactorybean is not the manager class that he wrote, and what function implements transaction control???

For:

Configure this class, is to now broadly implement the management of transactions, it can be said to be combined with hibenate, Transactionproxyfactorybean This class generally has three parameters to inject, one is hibernate Sessionfactory, this is for spring to be combined with hibernate, the second is the user's DAO class, and the DAO class itself needs to inject Hibernate's sessionfactory as a construction parameter into its parent class constructor. The third injection, in fact, is a policy of transaction management, implemented through AOP, such as having insert (String sql) in a DAO class, an update (String sql);d Elelte (String sql), three methods, We can set the operation of rollback when an exception is thrown when the insert executes. The landlord Control Rickhunterchen (Qian Shan bird fly) Huitie, can reflect what I said above. I understand the principle, but I don't know if I can express it clearly.

Transactionproxyfactorybean function and configuration in spring (RPM)

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.