in my p...">

Hibernate.hbm2ddl.auto = create no cleanup for existing data

I use

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

      

in my persistence.xml for my integration test, and when I run the integration test I get

ERROR SchemaExport:386 - Unsuccessful: create table tableName ...
ERROR SchemaExport:387 - Table 'tableName' already exists

      

but not hbm2ddl.auto = create Is it supposed to replace the table if it already exists? Why should I get this error?

BTW this worked as expected last week, so I am really confused as to why I am suddenly getting this error.

+3


source to share


3 answers


I ended up manually writing and executing the SQL statements to delete and recreate the schema, and then it worked as expected again. I never understood why Hibernate wouldn't crash and recreate existing tables, and it hasn't happened again since.



0


source


This error confuses me the first time. But the solution is pretty simple. Just change your hibernate.cfg.xml this setting:

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

      



to

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

      

0


source


The behavior changed in Hibernate 3.7 and was reverted back to 4.x I am assuming https://hibernate.atlassian.net/browse/HHH-6384 .

0


source







All Articles