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
- <!--setting up data sources-
- <Bean id= "DataSource" class= "Org.springframework.jndi.JndiObjectFactoryBean">
- <property name= "Jndiname">
- <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>
- </Property>
- </Bean>
- <!--settings Ibatis--
- <Bean id= " sqlmapclient" class= "Org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
- <property name= "configlocation">
- <value> Classpath:com/ayoa/bean/sqlmapdao/sql-map-config.xml </value>
- </Property>
- <property name= "DataSource">
- <ref bean= "DataSource"/>
- </Property>
- </Bean>
- <!--set up transaction management--
- <Bean id= " transactionmanager" class= " Org.springframework.jdbc.datasource.DataSourceTransactionManager ">
- <property name= "DataSource">
- <ref bean= "DataSource"/>
- </Property>
- </Bean>
- <!--set DAO--
- <Bean id= " Vssdao" class= " Com.wehave.hyerp.productmanage.persistence.sqlmapdao.VssSqlMapDao ">
- <property name= "sqlmapclient">
- <ref bean= "sqlmapclient"/>
- </Property>
- </Bean>
- <!--business layer to spring for transaction management--
- <Bean id= " vssservice" class= " Org.springframework.transaction.interceptor.TransactionProxyFactoryBean ">
- <property name= "TransactionManager">
- <ref bean= "TransactionManager"> </ref>
- </Property>
- <property name= "target">
- <Bean class= "Com.wehave.hyerp.productmanage.service.VssService">
- <property name= "Vssdao">
- <ref bean= "Vssdao"/>
- </Property>
- </Bean>
- </Property>
- <property name= "transactionattributes">
- <props>
- <prop key= "Insertvss"> propagation_required </prop>
- </props>
- </Property>
- </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)