1

我有一个带有 Spring + Maven + JPA (Hibernate) 的系统。我使用 Junit 和 DBUnit。我有一个生成 id 的实体:在测试期间它不会重置序列。我该如何解决这个问题?

4

1 回答 1

3

您可以尝试以下方法:

    @Before
    public void resetSequence() {
      // run sql to reset the sequence.
      // for DB without functionality to reset sequences (eg. oracle) you can try dropping and re-creating the sequence
    }

序列将在每次测试前重置。

于 2011-06-10T14:28:27.237 回答