在hibernate启动时删除所有表

Chr*_*ris 6 java hibernate

为了开发目的,如何在运行之前将所有表DROPS配置为hibernate?在运行我的代码之前,我不想经常手动DROP所有表.

我已经在使用了

<property name="hbm2ddl.auto">create</property>
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用,因为我遇到了几个错误,这些错误是由前一次运行的错误模式引起的.

编辑 也许我的问题有点误导.我想要一个干净的数据库.它不仅是因为实际的运行时错误,而且还因为每次运行都有一个干净的数据库.

<property name="hbm2ddl.auto">create-drop</property>
Run Code Online (Sandbox Code Playgroud)

忽略休眠不知道的表(如果您正在使用表名,这种情况可能经常发生).

Ant*_*sss 5

使用值create-drop代替create