当前位置:Gxlcms >
数据库问题 >
srping配合hibernate实现POJO与数据库表映射的零配置
srping配合hibernate实现POJO与数据库表映射的零配置
时间:2021-07-01 10:21:17
帮助过:24人阅读
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto} hibernate.show_sql=${hibernate.show_sql}
hibernate.format_sql=${hibernate.format_sql}
hibernate.cache.use_second_level_cache=${hibernate.cache.use_second_level_cache}
hibernate.cache.provider_class=${hibernate.cache.provider_class}
hibernate.cache.use_query_cache=${hibernate.cache.use_query_cache}
hibernate.jdbc.fetch_size=${hibernate.jdbc.fetch_size}
hibernate.jdbc.batch_size=${hibernate.jdbc.batch_size}
</value>
</property>
<property name="packagesToScan" value="com.ssbank.entity"/> </bean>
<bean id="databaseNamingStrategy" class="com.ssbank.common.DatabaseNamingStrategy">
<property name="tablePrefix" value="${namingStrategy.tablePrefix}" />
<property name="isAddUnderscores" value="${namingStrategy.isAddUnderscores}" />
<property name="maxLength" value="${namingStrategy.maxLength}" />
</bean>
注意: hibernate.hbm2ddl.auto=true时,项目启动会扫描com.ssbank.entity包下的所有实体bean,配合了hibernate提供的命名策略databaseNamingStrategy,在数据库生成相应的表。
srping配合hibernate实现POJO与数据库表映射的零配置
标签: