What is the method of integrating hibernate with spring
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.