gotch4
gotch4

Reputation: 13269

How to avoid using hibernate schema update

I use Hibernate in my day-to-day programming tasks and I find it very good. In particular I love the way it manages schema updates while developing, saving me from a lot of headaches.

Anyway they wrote on the docs that it is not recomended in production environment, understandably. So when I update an app on a production server, what can be the industry-standard way? I thought of creating an automated install procedure that dumps the database contents (a backup basically), then call hibernate schema update from code, then runs some tests on queries and so on. Anyway, are there tools around that would do this automatically and are well tested?

Speak out! :)

Thanks.

Upvotes: 5

Views: 1308

Answers (3)

mindas
mindas

Reputation: 26713

I personally think this recommendation is too cautious. We are using Hibernate auto update feature for a good number of years both in production and development and never had problems with it (and yes, we cater for lots of big systems and well known brands).

Obviously you have to test your application to ensure Hibernate does the right job when upgrading from one version to another, but the same applies for every other software aspect, too.

You also have to be aware of what auto-update can do (e.g. create new tables, add new indices) and what it can't (e.g. drop tables, remove constraints). The missing bits are reasonably easily doable with raw JDBC, again, not without testing.

Upvotes: 0

ChssPly76
ChssPly76

Reputation: 100706

Take a look at Liquibase. It's essentially a version control system for your database schema. It nicely integrates with Hibernate, too.

Upvotes: 3

JB Nizet
JB Nizet

Reputation: 691735

Look at Strategies for dealing with constantly changing requirements for MySQL schemas? for a similar question and its answer.

To make it short, once you have a reasonable amount of data and need to migrate it from one schema to another one, you'll need to write SQL scripts to alter your schema and move/transform data.

Upvotes: 2

Related Questions