Spring Hibernate Integration Study Notes

The goal is to integrate IOC container to manage the Hibernate SessionFactory, using Spring to let Hibernate transaction management.

Specific steps:

1. Add required jar package

2. Add hibernate configuration file: hibernate.cfg.xml, write the persistent class corresponding file .hbm.xml

3. The spring hibernate added to the configuration file

spring consolidate file:

 Example hibernate configuration file as follows:

<hibernate-configuration>
<!-- 配置hibernate的方言,sql显示及格式化,配置生成数据表的策略 -->
    <session-factory>
    	<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
    	<property name="hibernate.show_sql">true</property>
    	<property name="hibernate.format_sql">true</property>
    	<property name="hibernate.hbm2ddl.auto">update</property>
    </session-factory>
</hibernate-configuration>

Problems in the testing process, encountered:

1. Unable to initialize error, because a mistake hibernate configuration file, can not match.

2.sql statement is wrong, there should be in accordance with the class to write.

 

Published 14 original articles · won praise 0 · Views 4169

Guess you like

Origin blog.csdn.net/sky892012/article/details/104445908