In table-per-hierarchy approach we can have single table in DB as well as single hibernate mapping file containing mapping for each sub-class. Here we need discriminator to differentiate between different sub-classes and while loading or in HQL query we can use Base class.(In this case discriminator is must)
The same can be achieved by having separate mapping file per sub class, pointing to common table. (Considering each subclass has less common properties. and no subclass properties are sub set of properties of other sub class). But in this scenario while loading and in HQL queries we have to pass sub-class name, base class cannot be used for this purpose. In this approach we don’t need discriminator column in DB.
So which approach is better in terms of design and performance?
|