Using in hibernate

What does this tag do :

It tells hibernate to automatically sync up the table structure –Pojo to DB layer schema. There are couple of options which can go here:

validate: validate the schema, makes no changes to the database.
update: update the schema.
create: creates the schema, destroying previous data.
create-drop: drop the schema at the end of the session.

I suggest not to use this tag even for development, using it in production is any way nothing less than sin.

In a stressed environment (as it happened with me today), one might forget that this small tag is doing some magic and “automatically” changing the DB structure/deleting/ records et all.

1. I was running a test (DB layer test) for validating a schema change –and it was supposed to fail, because SQL has not been run.
2. Instead all the tests were passing, see even great news sometime smell bad.
3. A couple of tests later, When I verified the DB schema I saw all the DB “Automatically” updated with new schema.
4. As I had earlier worked on hibernate, It clicked and I verified the config file and got the answer to mystery.
5. Same would not have happened if I did not had experience in ORM, or at least it would have taken some time/help.

About ChandanPandey

Try to come up with a good design as by product of good coding practices

Posted on August 29, 2010, in Hibernate and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: