Can DbUnit insert rows with an identity/auto-incremented primary key column ?

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

Can DbUnit insert rows with an identity/auto-incremented primary key column ?

tomjbr.41338935
(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:

http://dbunit-net.sourceforge.net/GettingStarted.html#step4



So, can it
really be possible that there actually is no solution implemented yet for
this feature in DbUnit (which has been around much longer than the .NET version)
?



/ Tom



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user