OK, so this looks kind of like "table per class hierarchy" (
http://www.hibernate.org/hib_docs/refer ... leperclass).
But what should the discriminator value be? In this scenario, every record could be mapped by either class (that sounds a bit odd, but see the scenario at the end). And will it cause problems if you have two objects , one from each class, that map to the same row?
Another way to look at this is:
Course
|---- CoursePlusOptionalAssociations
CoursePlusOptionalAssociations only exists to add associations to Course. And then the question becomes:
How do I map a subclass which has no properties (and therefore needs no table) but does need to represent one end of an association?
Why would we want to do this? Let's imagine that Course is part of a framework or subdomain that sits underneath other parts of our domain model. We might have dozens of higher level modules that might want to associate with Course - billing, enrolments, timetabling etc. We might even want to access that same Course domain model from an entirely different application.
In this scenario, it's clearly inappropriate for the Course module to include association mappings to all the higher level modules. It's much better for the higher level modules to extend or decorate Course to include their own specific properties and associations, so you'd have BillingCourse, EnrolmentsCourse etc.
So what should the mapping for BillingCourse look like? It's equally inappropriate for the BillingCourse mapping to repeat all the mapping details that we already have in the Course mapping file - not DRY and a breach of encapsulation. If BillingCourse has persistable properties, we create a BillingCourse table and use "table per concrete class" using the nice <subclass extends=""...> mapping.
But what if BillingCourse has no persistable properties and extends Course only to provide an endpoint for associations to other billing objects? AFAIK, our options are:
1. Create a BillingCourse table anyway, purely to hang a subclass mapping on.
2. Have BillingCourse map back to the Course table. Just a very simple mapping with just the PK would do for this purpose.
3. Define BillingCourse as a <subclass> of Course with a discriminator that will include every row. Probably means that we have to use a different session factory for each high-level module.
If we choose the second option, this scenario starts to look very like the OP's "two classes mapping to one table" scenario.