Polymorphic Queries
One thing that is quite nice in Hibernate is the support for polymorphic queries. Let's say that I have a number of companies that I do business with - vendors and customers. They may be in different tables (lets say tbl_Vendor and tbl_Customer) if I implement a "one table per concrete class" inheritance strategy, but I can still query for all of the Companies that I do business with. If I'm using one table per concrete class, Hibernate uses a union of two queries plus the setting of null columns (to give vendors the customer columns and vice versa) to return the results of the query. Obviously if I'm using one table per class hierarchy, Hibernate can just run a simple query against the tbl_Company table to get the results.


There are no comments for this entry.
[Add Comment]