Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method of integrating hibernate with spring

Shulou Source: shulou.com Published: 2022-06-03 06:18:58 11月16日 Update

This article is to share with you about spring's method of integrating hibernate. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Structure:

Integration of Spring and Hibernate with the help of HibernateTemplate

ApplicationContext.xml

Com/lc/pojo/Category.hbm.xml hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.show_sql=true hbm2ddl.auto=update

Test:

ApplicationContext context=new ClassPathXmlApplicationContext ("applicationContext.xml"); CategoryDAO bean = (CategoryDAO) context.getBean ("dao"); DetachedCriteria criteria = DetachedCriteria.forClass (Category.class); / / List list = bean.findByCriteria (criteria, 0,5); / / pagination-take 0-5 returns / / System.out.println (list)

Category.hbm.xml

This is how spring integrates hibernate. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Integration methods more knowledge articles practical that is work meetings articles look knowledge points structure industry details information information channels follow parts channels learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Microsoft OPPO Reno Redmi