I am using Hibernate to develop web application.I have a point that after saving values from my web application to database in localhost.When I undeploy application from my localhost.All values in saved database are also being deleted.However table structure is there but values are empty?
I would never rely on hbm2ddl in a production environment. It's ok for development purposes, but a risk for a production envorinment. I always create my database scripts manually and execute them manually.
And it seems it's not only me who doesn't want to rely on hbm2ddl in a production environment. Here and here you'll find more user experiences.
write the ddl statements (to create/alter tables and other database objects) yourself and execute them manually
don't use hbm2ddl in your application
write 1 Dao for each entity with create, read, update, delete, find and other required methods
As for why Hibernate recreates empty database tables before each run (if that's what's actually happening): there's a configuration property which tells Hibernate to do that (or not). It's this one, if I'm not mistaken: