33

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
  • 34,055
  • 17
  • 142
  • 189
Anand K Nair
  • 587
  • 1
  • 6
  • 18

3 Answers3

48

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,146
  • 2
  • 29
  • 35
28

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

Already asked in SO . link

Community
  • 1
  • 1
Abhilash
  • 781
  • 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
  • 39,719
  • 12
  • 74
  • 101