springmvc的hibernate的配置操作

来源:互联网 发布:php 源代码 保护 编辑:程序博客网 时间:2024/06/03 23:41
#hibernate配置
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=true
hibernate.use_sql_comments=true
validationQuery=SELECT 1




<!-- 配置hibernate session工厂 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.use_sql_comments">${hibernate.use_sql_comments}</prop>
</props>
</property>


<!-- 自动扫描注解方式配置的hibernate类文件 -->
<property name="packagesToScan">
<list>
<value>cn.inovance.iotas.common.domain</value>
<value>cn.inovance.iotas.business.entity</value>
<value>cn.inovance.iotas.common.upkeep.entity</value>
</list>
</property>


<!-- 自动扫描hbm方式配置的hibernate文件和.hbm文件 -->
<!-- <property name="mappingDirectoryLocations"> <list> <value>classpath:sy/hbm</value> </list> </property> -->
</bean>