| When using joined-subclass inheritance, and searching on a field name that is shared between multiple subclasses, only the first mapping that contains the field name will be queried. Example: if we have SubClassA and SubClassB, both of which extend MySuperClass, and both of which have the field "fieldOnChild", the query "from MySuperClass where fieldOnChild = 'foobar'" will generate the following where-clause: WHERE subclassAalias = 'foobar' This will omit any results in SubClassB that might have matched. The following SQL should be generated instead: WHERE (subclassAalias = 'foobar' OR subclassBalias = 'foobar'); This is the simplest form to reproduce this behavior. I'm not sure it's technically correct at all, since the superclass does not have 'fieldOnChild' at all. However, the same behavior occurs when you specify a 'TYPE(c) = SubClassB' clause in the HQL, or if you use an intermediate subclass/interface that provides abstract getter/setter methods. I realize this probably makes the DBAs cringe because it's not fully normalized or denormalized, the proper answer would be to move the shared columns into a separate table, but the behavior here should either be to fail with an error or to work correctly, not silently generate incorrect SQL. |