Hibernate一个配置参数hibernate.hbm2ddl.auto
2010-06-09 09:44
513 查看
通过查资料,在别人整理出的Spring + JPA(Hibernate实现),从网上copy了一段Hibernate连接参数的配置。
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties> 结果在测试时,老是发现数据库表数据丢失。,最后才定位到这个上面。赶紧查了一下Hibernate的参数配置,解释如下:
hibernate.hbm2ddl.auto Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly. eg. validate | update | create | create-drop
其实这个参数的作用主要用于:自动创建|更新|验证数据库表结构。如果不是此方面的需求建议set value="none".
其它几个参数的意思,我解释一下:
validate 加载hibernate时,验证创建数据库表结构
create 每次加载hibernate,重新创建数据库表结构,这就是导致数据库表数据丢失的原因。
create-drop 加载hibernate时创建,退出是删除表结构
update 加载hibernate自动更新数据库结构
总结:
1.请慎重使用此参数,没必要就不要随便用。
2.如果发现数据库表丢失,请检查hibernate.hbm2ddl.auto的配置 可设置 <property name="hibernate.hbm2ddl.auto" value="none" />
3.此设置适合ejb配置文件修改
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties> 结果在测试时,老是发现数据库表数据丢失。,最后才定位到这个上面。赶紧查了一下Hibernate的参数配置,解释如下:
hibernate.hbm2ddl.auto Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly. eg. validate | update | create | create-drop
其实这个参数的作用主要用于:自动创建|更新|验证数据库表结构。如果不是此方面的需求建议set value="none".
其它几个参数的意思,我解释一下:
validate 加载hibernate时,验证创建数据库表结构
create 每次加载hibernate,重新创建数据库表结构,这就是导致数据库表数据丢失的原因。
create-drop 加载hibernate时创建,退出是删除表结构
update 加载hibernate自动更新数据库结构
总结:
1.请慎重使用此参数,没必要就不要随便用。
2.如果发现数据库表丢失,请检查hibernate.hbm2ddl.auto的配置 可设置 <property name="hibernate.hbm2ddl.auto" value="none" />
3.此设置适合ejb配置文件修改
相关文章推荐
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- Hibernate参数配置说明表hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- Hibernate配置文件hibernate.hbm2ddl.auto参数说明
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- 关于Hibernate一个配置参数hibernate.hbm2ddl.auto
- APN APN指一种网络接入技术,是通过手机上网时必须配置的一个参数,它决定了手机通过哪种接入方式来访问网络。
- 让Hibernate输出SQL语句以便更加深入调试程序----参数配置
- 记录一个 spring cloud 配置中心的坑,命令行端口参数无效,被覆盖,编码集问题无法读取文件等.
- Hibernate配置文件中hiberante.hbm2ddl.auto四个参数的配置
- MyEclipse自动生成Hibernate配置文件时的一个错误
- Hibernate类生成表以及一个hibernate数据库文件的配置