Announcement Announcement Module
No announcement yet.
Where is SchemaExport? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where is SchemaExport?

    Woops! I wish I could change the title: It should read "How to use DBUnit with Hibernate Session?".

    I just inherited a junit test that runs and passes. Since I want to modify it to use DBUnit and I'm encountering obstacles.

    Here is some new code I inherited:
    public abstract class AbstractTestCase { 
    // common ancestor sets up log4j 
    The descendants of this unit test are correctly extracting the username, password, driver name, database URL from the spring configuration files for hibernate and creating a hibernate session using the "@autowired" feature. This is very clever and I've spent all evening figuring out how this works.

    Now DBUnit needs this information (username, password, driver name, URL) too. How do I get it?
    (1) Can I extract it from the hibernate session object? I tried and I could not find it in the Session object using the eclipse debugger.
    (2) Where is the application context? I cannot find that either. Maybe I could read it in again and extract the username, password, URL etc... from the spring configuration file redundantly a second time? I've tried this too and I cannot make it work. I get another instance of the hibernate session object from which I cannot extact the username, password, URL and driver name.

    (3) Maybe I could make DBUnit work with a hibernate session object instead? I'm looking in the dbunit docs and cannot find any accommodation of such.

    (4) Is there a counterpart to SpringJUnit4ClassRunner.class that works with main programs?

    Last edited by siegfried; Sep 13th, 2009, 11:17 AM. Reason: clarify