I use NHibernate to load a large tree of objects of various types. Mapping is done using the table-per-subclass strategy. I defined the base class "Node", which has only a few fields (NodeId, ParentId, NodeType) and several subclasses that inherit from Node and add their own fields.
The implementation of this approach was simple, and I cannot complain about performance. A large tree of 10,000 objects of various types was populated on my old car for several hundred milliseconds using one circuit. However, one thing bothers me: this strategy leads to the generation of a complex query, where the Node table is external, connected to every other table corresponding to certain subclasses. Although this is normal when the number of different subclasses is small, if the number increases, the complexity of the OUTER JOIN will also increase.
Defining a table in a class does not seem to be an elegant option, and it will work slowly when selecting data from a base class (due to UNION). Other parameters seem to increase the number of calls to the database server.
So, what do you think is the best practice when populating a large tree consisting of objects of different types? Is there anything better than a table for a subclass?
source share