I have a very easy table (id, name, parent) that represents a tree. I want to use dbunit while testing this table, so I created a simple dataset for 2 nodes (yaml instead of xml for readability):
node:
- id: 1
name: default
parent: null
- id: 2
name: default-child
parent: 1
This gets inserted all right, but when trying to clean the table (I'm using DatabaseOperation.CLEAN_INSERT) it causes a constraint violation:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (node, CONSTRAINT FK_NODE.PARENT_TO_NODE.ID FOREIGN KEY (parent) REFERENCES node (id))
i found a workaround: using truncate_table operation instead of gentle clean operation works for me on mysql