Foreign key to same table

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Foreign key to same table

Thomas Scheffler

I recently came across the suggestion to use dbunit to migrate data
between different database vendors. While initially successful I came
into trouble when rows in tables references other rows of the same table.


internalID: int
name: varchar
parent: int (foreign key to internalID)

Now the tricky part is that the order entries in the IDataSet is not
deterministic. Is there a way, like for tables, to write out referenced
rows before referencing rows?

Currently I use this code to get the IDataSet:

ITableFilter filter = new DatabaseSequenceFilter(jdbcConnection);
IDataSet dataSet = jdbcConnection.createDataSet();
return new FilteredDataSet(filter, dataSet);

Neither Google or the API helped me to get further with that problem, so
I think it is not possible out of the box.

Did anybody faced this problem and found a working solution?



Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
dbunit-user mailing list
[hidden email]