Open raderio opened 7 years ago
I can reset it by running
TRUNCATE TABLE accounts RESTART IDENTITY;
How to make dbunit to do that?
Hi.
On my case dbunit inserts left a table with sequence in wrong state, because dbunit doesn't call Postgre nextval()
function. And after this we can't use any tools or libs such as PgAdmin or Hibernate with identity generation.
Solution based on idea from this post.
We need to call setval()
function after dbunit inserts.
Steps:
AbstractOperation
class to run a custom SQL operator.@DbUnitConfiguration
Example gist I think you can easily adapt it for your scenario.
CREATE TABLE accounts (id BIGSERIAL NOT NULL PRIMARY KEY);
@DatabaseTearDown(value = "clear.xml", type = TRUNCATE_TABLE)
@ExpectedDatabase
When I run first time everything is ok. But on second time I have an error