hibernate.hbm2ddl.auto配置详解

本文详细介绍了Hibernate配置中的`hibernate.hbm2ddl.auto`属性,包括`validate`、`update`、`create`和`create-drop`四种模式的含义和应用场景。特别强调了`create`模式可能导致的数据库表数据丢失问题,以及在不同场景下如何选择合适的配置以避免数据丢失。同时提醒开发者要谨慎使用该参数,并提供了关于数据库表丢失的排查建议。
摘要由CSDN通过智能技术生成

hibernate.cfg.xml 中hibernate.hbm2ddl.auto配置节点如下:
<properties>
<property name="hibernate.show_sql" value="true" /> 
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>

Hibernate Reference Documentation 3.3.1解释如下:
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值