The hibernate orm options, create, create-drop, update and validate.
Is there any one that says, create once, but don't drop or update?
An option that says, just create if don't exist, don't update, don't drop?
The hibernate orm options, create, create-drop, update and validate.
Is there any one that says, create once, but don't drop or update?
An option that says, just create if don't exist, don't update, don't drop?
The create-once as you are seeking doesn't exist as a hibernate flag. For your scenario it would be better to manage the DDL of your DB with an external tool and not use the hibernate.hbm2ddl.auto
. Pesonally, I can recommend http://www.liquibase.org/, its advertised as a source control for the DB and it really supports development well, when working against different branches with a fast changing model.
Liquibase is centered around the changeLog.xml file, that store all the changes applied to the DB. So when you make a change to your model, you generate a diff resulting in xml entries for the changeLog.xml. The underlying DB keeps track of the applied changes, so you can, re-create, apply update, generate migrate SQL, empty DB or leave as is, you're in control.
Here is an existing discussion that summarizes the options of hibernate.hbm2ddl.auto. hbm2ddl discussion
It is common for shops that use Hibernate to manage the physical database layer separately, using SQL DDL scripts run directly by DBAs for example, rather than allowing Hibernate tools to modify the database schema. If you still wish to have Hibernate run these for you, the hibernate.hbm2ddl.import_files option can be used to tweak your DDL operations manually by providing custom script files.
In your case if you wish to let your ORM dictate the phsyical model as opposed to the reverse, you could just leave your hbm2ddl.auto as 'update'. The other option would be to programmatically generate your script files referenced in hibernate.hbm2ddl.import_files using entity mapping or meta-data(annotations) as the guiding input.
I had to write my own solution for this. This is not possible using hibernate or jpa.