34

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

???

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
Anand K Nair
  • 597
  • 1
  • 6
  • 18

3 Answers3

50

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);
}
raphaëλ
  • 6,393
  • 2
  • 29
  • 35
28

Just omitting hibernate.hbm2ddl.auto defaults to Hibernate not doing anything.

Already asked in SO . link

Community
  • 1
  • 1
Abhilash
  • 792
  • 2
  • 7
  • 17
16

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
Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103