*
The moose likes Testing and the fly likes DBUnit: Composite Unique Key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "DBUnit: Composite Unique Key" Watch "DBUnit: Composite Unique Key" New topic
Author

DBUnit: Composite Unique Key

Sam Mascarenhas
Greenhorn

Joined: Jun 24, 2010
Posts: 1
Hello,

Trying to insert into a database table with DBunit however, since the table doesn't explisitly define a primary key. The table defines a unique composite key. DBunit fails while execution with a "org.dbunit.dataset.NoPrimaryKeyException"... googled on this one and came across the following helpful site - http://dbunit.wikidot.com/noprimarykeytable...

With reference to the sample provided on this site... the issue is that it only supports defining a single primary key field.......Similarly, how do we provide it with a composite key...

Please advise.

Sam
Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
I've bumped on this question while having the same problem. Didn't find much resources about this so I decided to share what I eventually came up with. I've found some old post from 2005 (http://www.systemmobile.com/?p=102) which gave me the idea that worked. Take a look at the following code sample which shows how to do it for composite keys:



Hope that this helps (at least to someone who bumps as I did).
Edit: I wrote an article with more details as reminder on my blog. Here it is dbunit with composite primary keys


http://www.expertaya.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBUnit: Composite Unique Key
 
Similar Threads
Hibernate - Autogenerate composite keys
ATG Framework
DBUNIT Exporting data from table with composite id?
Mapping same POJO to two tables in Hibernate XML mapping files
composite-id in Hibernate