Page 1 of 1

Whenever i run application, deleting old data in database

Posted: Fri May 29, 2015 7:55 am
by d8sasi
Hi Team,
Whenever we updating the Tables with Records, if i again run my application it is dropping all the Data Base Tables and again creating new database tables. So by this i lost my previous data what ever i have updated earlier in my Database.
Please tell me how to overcome this Issue. ?

thanks for reading,
Great Day.

Re: Whenever i run application, deleting old data in database

Posted: Mon Jun 01, 2015 4:41 pm
by phillipuniverse
In site, development-properties for blPU.hibernate.hbm2ddl=create-drop. If you change this to create instead it will not drop the data when it shuts down.

Re: Whenever i run application, deleting old data in database

Posted: Tue Jun 02, 2015 2:31 am
by d8sasi
thanks phillipuniverse for the information.

Here is some useful information about hbm2ddl property.
Hibernate.hbm2ddl.auto is a property which you can set in hibernate configuration. This will run DDL for the Database. The values for this property are 
validate | update | create | create-drop 
Validate = will validate the schema that you have, and makes no changes to the database. 
Update = will update the database if the schema is already there in the database. 
Create = will create new database, removing existing schema if any 
Create-drop = will create new database and drops it when the sessionFactory is destroyed. 

Great Day,