Configuration of four declarative transactions in spring there are two ideas that are important in the spring container, which is our common IOC and AOP, and if these two ideas are understood, it is very helpful for us to learn design patterns and programming, in the design pattern written by gang (GOF) in the United States, Many of them have been used in the minds of the IOC. Simply put is the thought of dependency injection. A common scenario: if you want to reuse functionality from another class in a class, we may think first of inheritance, if you know the idea of the IOC, I think you will not use inheritance, you will immediately think of the use of the function to extract, in the class we want to use only through the set method of simple injection can be, In fact, this use of the combination of objects instead of inheritance, so as not only to avoid a single inheritance, but also a good implementation of loose coupling. It also follows the design principle of object-oriented programming: Multi-use combination, less inheritance. Here are the benefits of both the IOC and the AOP ideas. I will not introduce. The next thing I want to say is that several common transaction configurations in spring are fully embodied in AOP and the IOC.
On the Han, formerly EJB in the Java EE development in the famous. It is because EJB provides a lot of service, and does not need us to develop, which uses most of the declarative transactions it provides. EJB plays a very important role in the development of Java EE before spring is present. It is also a major contributor to many project failures. The reason for this is that it is a framework for heavyweight, aggressive fees. The need for expensive server support, in addition to its testing is a headache. And spring is exactly the opposite of it. Spring is a lightweight, non-intrusive, open source framework. It provides declarative transactions that are more powerful and do not require container support. This attraction many people are willing to give up EJB and use spring. Let's get to the point.
The following two bean configurations are used below.
<!--define the transaction manager (declarative transaction)-->
<bean id= "TransactionManager"
class= " Org.springframework.orm.hibernate3.HibernateTransactionManager "
<property name=" Sessionfactory ">
<ref local= "sessionfactory"/>
</property>
</bean>
<!--******* business Logic layer (yes The front package for each DAO layer is mainly used in the << façade mode >>******
<bean id= "Fundservice"
class= com.jack.fund.service. Serviceimpl. Fundservice ""
<property name= "Operdao"
<ref bean= "Operatordao"/>
</property> ;
<property name= "Producedao"
<ref bean= "Fundproducedao"/>
</property>
<property name= "Customerdao"
<ref bean= "Customerdao"/>
</property>
<propert Y name= "Accountdao"
<ref bean= "Accountdao"/>
</property>
<property name= "Funda" Ccountdao ""
<ref bean= "Fundaccountdao"/>
</property>
<property name= "Fundtransdao"
<ref bean= "Fundtransdao"/>
</property>
&L T;/bean>