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中问过了。 链接
- 使用nolock进行Java Hibernate HQL查询
- 如何修复错误:“INFO:HHH000206:找不到hibernate.properties”?
- 使用Spring AOP配置Hibernate会话
- 如何使用hibernate生成Custom Id,同时它必须是表的主键
- BeanFactory未初始化或已关闭 – 之前调用’刷新’
- java.lang.NoClassDefFoundError:无法初始化类org.hibernate.ejb.Ejb3Configuration
- 在运行时获取有关entites的hibernate信息
- 从MySql迁移:MariaDB服务器意外关闭客户端连接
- 实现AbstractMultiTenantConnectionProvider