SoFunction
Updated on 2025-03-08

Example explanation of integrating hibernate based on existing spring

1.3 Importing the dependency package of dbcp

2. Import hibernate packages and spring packages

3. 4 Import hibernate3's dependency package (all in hibernatejar, require files, sif4-api.jar, packages in jpa folder)

4.2 Create a hibernate sessionFactory

5. Create applicationContext.xml

6.2 Import log4j dependency package

7.1 Import Spring's dependency package

8. Configure spring transaction processing

9. Add annotation or hbm file to entity class

10.2 If you manage the corresponding SessionFactory through spring, you no longer use factory.openSession(), but factory.getCurrentSession() to open the session, and this session will be managed by spring.

11.1 Create dataSource using DBCP (same as integrating JDBP)

12. Create a DAO based on hibernate

13. 1 Inject the corresponding SessionFactory into the corresponding DAO