Can DbUnit insert rows with an identity/auto-incremented primary key column ?
(To avoid misunderstandings, please note that my question is _not_ about the
frequent question about how to disable identity with SQL Server, since I know
that can be done with IdentityInsertOperation)
I would like to be able
to use a snapshot copy of an existing database (using SQL Server identity
primary keys) and in the XML file (i.e. the file which is used by my DBTestCase
subclass method 'getDataSet()' ) I want to be able to define one or two additional
rows that my tested methods will try to update and delete.
My problem is
that I can not realize how I can avoid being forced to explicitly specify
the primary key value in the XML file (and instead letting the database provide
the value at the insertion, when DbUnit inserts the row).
I have tried
to simply not providing any value for the identity primary key field, but
then DbUnit complains about NoSuchColumnException.
I checked out the DbUnit.NET
project and easily could find that they seem to have a solution (including
how to retrieve the autogenerated identity value) already in their alpha release: