In my case, I have two peer classes, one 'summary' one 'detail'. For performance reasons, I want to send hibernate my search criteria, return back a collection of Summary objects, allow the user to pick the real object, send hibernate the id of that object, then bring up the detail object in a details page. Pretty straightforward - think Google's standard search flow of criteria - select-from-summary-list - navigate-to-detail.
The test harness is using junit to start up an empty hsqldb, with hbm2ddl.auto set to 'create'. The schema should be created, a post-creation sql script run (it loads the standard dataset) and then progress to the junit tests.
When I introduce the Summary object, the hbm2ddl phase of things seems to attempt to create the underlying database table twice. Of course, it seems to decide to create the summary table first (though I can't actually find evidence of this create-table statement being executed...), then fails creating the _real_ detail-flavor of the table second. Since all the detail fields are missing, the rest of the loading goes to heck.
When I change the mapping document of the summary class to a new table, things seem to work ok - aside from the fact that this new table now has no data, and the junit tests fail as expected.
So. Is there a way to have multiple classes all map to a single database table, but to have only one 'master' flavor of the table created?
Running hbm2ddl.auto in 'update' mode hasn't worked yet.