I have the following quite strange dataset for DBUnit:
<persons id = "1"
first_name ="TestName99"
second_name = "TestSecondName"
father_name = "TestFatherName"
phone_number = "123456789"
date_of_birth = "1985-12-12 00:16:14"
role = "ROLE_OWNER"
date_of_creation = "2016-09-23 23:09:28"
enable = "1" />
<carwash id = "1"
name = "TestCarWash"
address = "test car wash address "
phone_number = " 123456789"
box_count = "5"
first_shift = "08:00:00"
second_shift = "20:00:00"
created_by = "1"
date_of_creation = "2016-09-23 23:09:28"
enable = "1" />
<persons id = "2"
first_name ="TestName100"
second_name = "TestSecondName"
father_name = "TestFatherName"
phone_number = "123456789"
date_of_birth = "1985-12-12 00:16:14"
role = "ROLE_WASHERMAN"
date_of_creation = "2016-09-23 23:09:28"
carwash = "1"
enable = "1" />
the most strange thinks is persons
table has foreign key to carwash
however this column is nullable (therefore you cannot find carwash
in person with id=1
) and carwash
table has FK to persons
in column create_by
This scheme leads to special order for put data in DB. As I understand DBUnit doesn't put value in DB based on order the value mentioned in dataset by default. And consequently when this dataset is executing it lead to exception
MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`test_pitstop`.`persons`, CONSTRAINT `persons_ibfk_1` FOREIGN KEY (`carwash`) REFERENCES `carwash` (`id`))
Is any way to push DBUnit put data in DB in string order as it mentioned in xml ?