Hierarchy - How do I construct DBUnit datasetwhatever to insertclean a table with tree-like data

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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))

Answers

i found a workaround: using truncate_table operation instead of gentle clean operation works for me on mysql

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/5290193/how-do-i-construct-dbunit-dataset-whatever-to-insert-clean-a-table-with-tree-lik

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils