Reputation: 601
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
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