views:

39

answers:

1

Is the database generated by Hibernate when using ormsettings.dbcreate = "dropcreate" good for production use?

My Case: Basically were designing the database, and i thought it would be cool to design the objects and have hibernate create the database for me.

+2  A: 

It's not a matter of good or bad. I would say its a question of deployment or even business context.

Do you need to Drop all the tables (hence the data) and recreate them? If it's a fresh deployment, then it doesn't really make a difference. If you already have the production database, I do not see why you would want to drop the existing tables unless in scenarios like an overhaul or total revamp.

UPDATE:
For you case, it's a good start to have the DB created according to the Hibernate mapping, saves you some time. I would not recommend it for direct production use without it being tested say for development or staging. I use NHibernate's tools to generate the schema for my DB as well, but it is for me to verify that my mapping works and I tweaked it along the way. The final production-ready schema is actually a copy from my staging DB. But it should work well for you to use your method.

In short, always double check.

o.k.w
Just added my case
Faisal Abid
@Faisal: Updated my post.
o.k.w
Thanks, that makes alot of sense. Basically thats what I was going to do, let Hibernate generate the schema, and test it (since the project is in development), and test the DB , later one when were about to launch, optimize the current schema. Sound Reasonable?
Faisal Abid
Oh yes, you got my point:)
o.k.w
Thanks So Much!
Faisal Abid