What does this tag do : hbm2ddl.auto
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.