• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DBUnit: Composite Unique Key

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
money grubbing section goes here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic