title: Hibernate H2 specify drop table order
body: <p>I have pretty much the same problem like <a href="https://stackoverflow.com/q/59364212/7840514">this user</a>. Hibernate can't drop the tables of my in-memory test database after each SpringBootTest (e.g. when running mvn test). The desired behavior would be <code>ddl-auto=create-drop</code>, but this doesn't work.</p>
  <p>I think the reason could be an invalid order of the <code>DROP TABLE</code> statements, so that Hibernate tries to delete tables on which other tables still depend on.</p>
  <p>My data.sql script only contains <code>INSERT</code> statements and the schema is automatically created based on my entities. I tried adding <code>DROP TABLE</code> statements to the top of data.sql and they all pass (<code>ddl-auto=create</code>), because I can specify the order in which they have to be dropped.
  On the other side, I now have to specify the schema creation in data.sql too..</p>
  <p>Is there a way to specify the order of drop statements while not having to specify the schema creation? Or does anyone know a solution for the <a href="https://stackoverflow.com/q/59364212/7840514">initial problem</a>?</p>
  <p><strong>EDIT:</strong></p>
  <p>I want to give an example. I have an <code>User</code> entity that has relationships to other entities (M:N, 1:N, 1:1). When the schema is created, hibernate drops all tables, creates them and adds constrains:</p>
  <pre><code>// first test file:
  Hibernate: drop table user if exists
  ... // drop other tables
  Hibernate: create table user (username varchar(255) not null, ... , primary key (username))
  ... // create other tables
  Hibernate: alter table X add constraint FKgi38hy0tsrdm332gdjrc0uhm3 foreign key (username) references user
  Hibernate: alter table Y add constraint FK5svpy1b71l4jxni0xylrbbdtv foreign key (username) references user
  Hibernate: alter table Z add constraint FK5a8fxbb0ug3eo1lisdrrxbbj foreign key (username) references user
  
  // next test file:
  Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop &quot;USER&quot; because &quot;FKGI38HY0TSRDM332GDJRC0UHM3, FK5SVPY1B71L4JXNI0XYLRBBDTV, FK5A8FXBB0UG3EO1LISDRRXBBJ&quot; depends on it; SQL statement:
  drop table user if exists [90107-200]
  </code></pre>
  <p>This process doesn't work after the first test file, because it violates the constrains. This is why I wanted to specify the drop order.</p>
  <p>I don't use CascadeType on my entities, could that cause the problem?</p>