Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate: hbm2ddl.auto=update in production?

Is it okay to run Hibernate applications configured with hbm2ddl.auto=update to update the database schema in a production environment?

like image 403
cretzel Avatar asked Oct 21 '08 10:10

cretzel


People also ask

What is Hibernate hbm2ddl auto update?

hbm2ddl. auto 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.

When we set update as value for hbm2ddl auto property What will happen?

auto update : If the value is update then, Hibernate checks for the table and columns. If a table doesn't exist then it creates new tables and where as if a column doesn't exist it creates new columns for it.

Which of the following values can be used for Spring JPA Hibernate DDL Auto Property?

You can set spring. jpa. hibernate. ddl-auto explicitly and the standard Hibernate property values are none , validate , update , create-drop .


1 Answers

No, it's unsafe.

Despite the best efforts of the Hibernate team, you simply cannot rely on automatic updates in production. Write your own patches, review them with DBA, test them, then apply them manually.

Theoretically, if hbm2ddl update worked in development, it should work in production too. But in reality, it's not always the case.

Even if it worked OK, it may be sub-optimal. DBAs are paid that much for a reason.

like image 69
Vladimir Dyuzhev Avatar answered Oct 05 '22 15:10

Vladimir Dyuzhev