christian wrote:
I think it is not possible to map polymorphic associations without additional "any" discriminator columns if you require "table per concrete class". This is really not a good design decision, can't you switch to "table per sublass"?
Thanks for your interest, I have looked into the table per subclass strategy.
I *think* I understand this model, and switching to that for us would basically mean to add a table baseclass (id int, parentid int) and adding an entry for every single object in the system in that table (because all objects inherit from baseclass).
That would be feasible, however we have our own o/r mapping solution in place right now that we would have to throw away. With the table per concrete class strategy, the db schema remains the same and so we can still switch between Hibernate and our custom persistence manager. This is very desirable for many business reasons.
I am also concerned with the number of table joins that strategy implies. Sometimes, we join 10 tables to find an information and performance is an issue.
The bottom line is what is the drawback of using table per concrete class with many-to-any relationship, besides it not being a good relational design? I see table 16.1 in the docs says there a few features I cannot use, but all we need really is a bidirectional link where the parent has non polymorphic child but the child has a polymorphic parent.
Thanks for sharing your thoughts