Pages

When to choose which strategy for inheritance mapping?

When to choose which strategy for inheritance mapping?

There are few rules for choosing inheritance strategy.
(1) If there is no need for polymorphic association and queries i.e if you use very rarely query for CreditCardHolder or you do not have any class that has association with CreditCardHolder class, That time you should use UNION based mapping ( Table per concrete class with union).

(2) If you requires a polymorphic association  or queries and subclasses has few properties That time , you should use table per class hierarchy (using subclass element in mapping metadata file).

(3) If you requires a polymorphic association  or queries and subclasses has many properties That time , you should use table per subclass (using join-subclass element in mapping metadata file) and if width and depth of inheritance hierarchy is high that time you should use Mixing inheritance strategy.


2 comments: