Both classes map to the same table. Each UserEx class has it's own full mapping and only the appropriate mapping depending on the bridge chosen is loaded.
This seemed to be perfect for the 'table per class hierarchy' strategy. Only one problem, I had no discriminator columns nor any need for one as I was only going to have one sub class.
I got around this by declaring my classes as such:
class User
{
// user properties
}
class UserEx: User
{
// expanded user properties
}
And my mappings as such:
<class table="appr. table" name="User" value="null">
<id ... >
<discriminator-value formula="">"/>
// property mappings
</class>
<subclass name="UserEx" extends="User" value="">">
// property mappings
</subclass>
While this works like a charm, it would be nice if Hibernate/NHibernate would expand the 'table per class hierarchy' strategy to handle more gracefully this scenario.
Cheers for that hint. I have several subclasses with no added properties, just additional API to help enforce usage of the base class. But NHibernate was not too happy in dealing with the subclasses :)
ReplyDelete