Hibernate hbm2ddl.auto default value
71,759
Solution 1
Automatically validates or exports 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.
validate | update | create | create-drop
- validate- existing schema
- update- only update your schema once created
- create- create schema every time
Solution 2
That is really the answer: no validation, no update, no creation and no dropping takes place when omitting the setting from your configuration. The hibernate source code is the best documentation on 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);
}
Solution 3
Just omitting hibernate.hbm2ddl.auto defaults to Hibernate not doing anything.
Already asked in SO . link
Author by
Anand K Nair
Updated on April 02, 2020Comments
-
Anand K Nair about 4 years
What is the default value of
hibernate.hbm2ddl.auto
in hibernate cfg file mapping
is it possible to remove
<property name="hibernate.hbm2ddl.auto">update</property>
this mapping from config file
if i remove this property whether it affect my DB
???