• 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 and Hibernate hbm2ddl.auto, best practices...

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying to get some test infrastructure setup for a project using both DbUnit and Hibernate's hbm2ddl.auto setting.

In an earlier project with hbm2ddl.auto (instead using hand-coded DDL scripts), I had a working setup using DbUnit's CLEAN_INSERT option in test setUps, and no-ops in tear-downs. This was great as it allowed manual inspection of the test database after the test failed (when only that test was run, of course).

With hbm2ddl.auto, I get foreign key exceptions during the CLEAN_INSERT setUp. I'm assuming I didn't see these in the earlier case because I had enough "on delete cascade" claues, and just got lucky with the order that DbUnit was delete things. (Since i do have some on delete restricts in there, I would beleive I could hit the same problem on that project at some point in the future)

(Yes I know that DbUnit deletes in reverse order when the delete happens in the teardown, but DbUnit can't know an order in the CLEAN_INSERT case since that would require the test to know which test ran before, in order to figure out (via some unknown channel) which xml file was used to populate the database.)

Has anyone come across a good approach for using DbUnit and hbm2ddl.auto?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic