Rajesh G
Rajesh G

Reputation: 1

hbm2ddl.auto= create/create-drop will it remove data also?

In Hibernate if we set hbm2ddl.auto to create/create-drop , then it will delete the old schema and create the new schema when starts. It means, it will delete data also?.. My doubt is if it deletes every thing then how could we retrive the old data? (eg: user registration details) and what is the correct option should use in production environments?

Pls correct me, if I am wrong.

Upvotes: 0

Views: 3987

Answers (3)

Olgun Kaya
Olgun Kaya

Reputation: 2589

It basically drops the managed entity tables (not all of them in the scheme) on shutdown and recreates them on startup back again. Means as per your question; yes data is dropped from the tables as well. It does not drop the the whole schema but only the entities in the entity manager.

Upvotes: 1

xyz
xyz

Reputation: 5427

validate- existing schema

update- only update your schema once created

create- create schema every time.

Also here is a good explanation Hibernate hbm2ddl.auto possible values and what they do?

Upvotes: 0

Antoniossss
Antoniossss

Reputation: 32535

what is the correct option should use in production environments?

IMHO, the only valid option for production environements is validate. Everything else can cause potential risk of loosing data/breaking db schema due to misscofiguration, simple mistake or typo.

Use migrations tools for schema updates as they provide "version controll" over your schema allowing it to be tested before depoyment, and revert the changes.

Upvotes: 0

Related Questions