In previous JdbcTemplate, the transaction was submitted successfully, and exception handling was done through Try/catch, and in spring. The spring container integrates transactiontemplate, encapsulating all of the transactional functions, including transaction rollback at the time of the exception, and complex business functions such as data submission when the operation succeeds. This is managed by the spring container, greatly reducing the amount of code for the programmer, and also has good administrative control over the transaction. Hibernate also has the management of transactions, hibernate in the transaction management is through the Sessionfactory creation and maintenance session to complete. Spring also integrates the Sessionfactory configuration without having to set the sessionafactory through Hibernate.cfg.xml.
This will make good use of sping for transaction management. It avoids the need to get the session instance to start the transaction/COMMIT/ROLLBACK TRANSACTION and the tedious Try/catch operation for each data operation. These are good applications for the AOP (aspect-oriented programming) mechanism in spring. On the one hand, the development of business logic clearer, professional division of labor more easily. On the other hand, the application of SPIRNG AOP isolation reduces the coupling of the program so that we can combine the various facets in different applications to greatly improve the code reuse degree.
The benefits of spring's business management