An example of integrating hibernate on the basis of existing spring
1. Import hibernate package and spring package
Hibernate 3, hibernate-jpa-2.0-api -, required packages, log4j, log4j configuration files
1.1 import the dependency package of spring
1.2 import log4j dependent packages
1.3 importing dependency packages of DBCP
1.4 import hibernate 3 dependent packages (hibernate 3.jar, all in the require file, sif4-api.jar, packages in JPA folder)
2. Create ApplicationContext xml
2.1 create datasource using DBCP (same as integrating jdbp)
2.2 create hibernate sessionfactory
Including hibernate cfg. XML with references:
3. Add annotation or HBM file for entity class
4. Create a hibernate based Dao
4.1 inject the corresponding sessionfactory into the corresponding Dao
4.2 if the corresponding sessionfactory is managed through spring, the factory is no longer used Opensession(), instead of factory Getcurrentsession () to open the session, which will be managed by spring.
5. Configure spring transaction processing
The above example of integrating hibernate on the basis of existing spring is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.