How can I configure hibernate in a way that it DROPS all tables before it runs, for developement purposes? I don't want to constantly DROP all tables by hand before running my code.
I'm already using
<property name="hbm2ddl.auto">create</property>
But this does not seem to work, since I ran into several errors that where caused by wrong schemas from a previous run.
Edit Maybe my questions was a bit missleading. I want to have a clean database. Its not only because of actual runtime errors but also about having a clean database for every run.
<property name="hbm2ddl.auto">create-drop</property>
Ignores tables that are unknown to hibernate (which can happen quite often if you are playing around with tablenames).
Use the value create-drop
instead of create
Another possibility to get an always clean database at startup in a development environment is an in memory db like H2 or similar. See http://www.h2database.com/html/features.html#in_memory_databases for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With