Hibernate hbm2ddl.auto默认值

什么是默认值

hibernate.hbm2ddl.auto 

在hibernate cfg文件映射中

有可能删除

 update 

这个来自配置文件的映射

如果我删除此属性是否会影响我的数据库

???

创建SessionFactory时,自动validation或将架构DDL导出到数据库。 使用create-drop,当SessionFactory显式关闭时,将删除数据库模式。

 validate | update | create | create-drop 
  • validation – 现有架构
  • update-仅在创建后更新您的架构
  • 每次都创建 – 创建模式

这就是答案:从配置中省略设置时, 不进行validation, 不进行更新, 不进行创建, 也不进行删除。 hibernate源代码是关于Hibernate的最佳文档:

 // from org.hibernate.cfg.SettingsFactory line 332 (hibernate-core-3.6.7) String autoSchemaExport = properties.getProperty(Environment.HBM2DDL_AUTO); if ( "validate".equals(autoSchemaExport) ) settings.setAutoValidateSchema(true); if ( "update".equals(autoSchemaExport) ) settings.setAutoUpdateSchema(true); if ( "create".equals(autoSchemaExport) ) settings.setAutoCreateSchema(true); if ( "create-drop".equals(autoSchemaExport) ) { settings.setAutoCreateSchema(true); settings.setAutoDropSchema(true); } 

省略hibernate.hbm2ddl.auto默认为Hibernate没有做任何事情。

已经在SO中问过了。 链接