s.susini
s.susini

Reputation: 601

DBUnit doesn't reset sequences

I have a system with Spring + Maven + JPA (Hibernate). I use Junit and DBUnit. I have an Entity with generated id: during tests it don't reset the sequence. How can I solve this?

Upvotes: 1

Views: 2178

Answers (1)

happymeal
happymeal

Reputation: 1413

you can try the following:

    @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
    }

the sequence will reset before every test.

Upvotes: 3

Related Questions