Tuesday, 21 August 2012

Hibernate/JPA Create-Drop Known Issue

Often, running Hibernate/JPA in create drop mode:

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

generates multiple errors like this:

  Unsuccessful: alter table XXX drop constraint YYY

Thanks to feedback from Mikko Maunu on StackOverflow, the following issue can be explained by the fact that Hibernate does not check whether an object exists when it deletes it. The underlying database often triggers an error.

Since the create-drop mode drops many objects, these errors happen frequently, but can be ignored.