Pending DbUnit FAQ

This page is a collection of DbUnitFaq that only applies to the latest development code located in the DbUnit CVS repository. They will probably be integrated into the official DbUnitFaq at the next DbUnit release.

You have an idea for a new FAQ and it applies to an official DbUnit release? Add it to DbUnitFaq.

1. How to automatically add the DOCTYPE when writing a flat XML dataset?

FlatXmlWriter datasetWriter = new FlatXmlWriter( 
            new FileOutputStream("dataset.xml")); 

2. How to use InsertIdentityOperation with user defined types?

The IColumnFilter interface is now used by InsertIdentityOperation to detect identity columns. The default implementation assumes that type name of identity columns end with "identity". If you are using user defined types that does not follow this assumption you can now provide your own implementation via the "MS SQL identity column filter" property.

IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
        new MyIndentityFilter());

Note: The property name has been modified on May 17, 2004 for more consistency.

3. How to customize primary keys detection?

The IColumnFilter interface can also be used to determine which columns are primary keys instead of using DatabaseMetaData.getPrimaryKeys(). This can be useful if your primary keys are not explicitly defined in your database model (See the NoPrimaryKeyTable page for an example).

IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
        new MyPrimaryKeyFilter());
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License