I read in your changelog that self-referencing tables was supposed to be fixed (2439408) in v.2.4.1, but I can't really see that it is. I am using v.2.4.8 in combination with excel spreadsheets for holding the data. I get errors when I add a self-reference to tables.
I have a table Application, which contains the following fields: (id, name, nextVersion_id). If I have data set up like this:
(1, SomeApplication, 2)
(2, SomeApplication, )
I get the following error on all tests that uses dbUnit:
java.sql.SQLException: Integrity constraint violation - no parent FK93F0B94270757822 table: SOKNAD in statement [insert into APPLICATION(ID, NAME, NEXTVERSION_ID values (?, ?, ? )]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.execute(Unknown Source)
at org.dbunit.database.statement.SimplePreparedStatement.addBatch(SimplePreparedStatement.java:80)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addBatch(AutomaticPreparedBatchStatement.java:70)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:195)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
Thrown by a call to DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);
I'm guessing that this is due to the referencing entry being created before the referenced entry. But, when I flip the two:
(2, SomeApplication, )
(1, SomeApplication, 2)
The first test run will execute, but the following will throw:
java.sql.SQLException: Integrity constraint violation FK93F0B94270757822 table: APPLICATION
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source)
at org.dbunit.database.statement.SimpleStatement.executeBatch(SimpleStatement.java:69)
at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:126)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
I'm guessing that this has something to do with the CLEAN part of DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);, that it removes stuff in reverse order, resulting in an attempt to remove a referenced entry before the referencing entry is removed, and thus a constraint violation.
Is it possible to have the clean part go through the entries in the same order as the create part?
Still encounter this problem? Did you find the cause?