During project development, we’re auto creating our database when the application initiates. This is superuseful initially, especially when the database is based on the domain objects rather than the other way around. Since switching to MySQL and a ‘real’ database, rather than one in memory, there are a few gotchas. The one which caught me out this morning, for a few hours, involved adding and removing foreign keys automagically… it doesn’t really work!
anyway, we were set - hibernate.hbm2ddl.auto=create
when actually, we should have used create-drop.
create will empty the database, whereas create-drop will properly drop it…
for completeness, here is the configuration for a entity manager, with the generate DDL parameter switching the ddl generation on and off, and the hibernate.hbm2ddl.auto parameter determining whether you do a create each time or an update or whatever.