2

We are having some problems with hibernate and the auto-creation of the ddl in our hsqldb.

We use

<property name="hibernate.hbm2ddl.auto" value="create-drop"/>

Usually hibernate creates the tables in the schema on the db automatically when we change a mapped object, but sometimes it refuses to do that. In that case we have to delete the DB manually from filesystem to convince hibernate to recreate all the tables.

Does anybody know how hibernate decides when to recreate the datamodel on the db? I have read that it decides that when the SessionFactory is beeing created, but what are the exact conditions that convince hiberbate to update or create the tables?

Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
treeno
  • 2,510
  • 1
  • 20
  • 36
  • If it's not deleting, it's probably because there's some lock or something on the table at that time that is preventing Hibernate from dropping it. – AHungerArtist Mar 09 '12 at 15:49
  • yeah, that would be something that I can understand, but we also have the problem, when we drop the schema and recreate it manually. So the schema is completly empty, therefore I think there cannot be any locks left. – treeno Mar 09 '12 at 16:32
  • I also changed the schema that the application uses to a new one and again, hibernate refuses to create the tables. And without any furthor changes at the application, it works after deleting the db from filesystem – treeno Mar 09 '12 at 16:33
  • Is there anything in the Hibernate debug logs that indicate why it might be doing this? – AHungerArtist Mar 09 '12 at 17:08

1 Answers1

5

In your hibernate config file you this option:

<property name="hbm2ddl.auto">update</property>

change update to create, or create-drop or validate, whichever you want it to be.

Or if you have the setting correct and it is not doing what you expect check the log messages, and turn logging level up if required.

Community
  • 1
  • 1
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311