Exception when selecting from a subclass in single table inheritance when another entity has 1-1 attributes of other subclasses
Description
Running the simple
query on the domain model described in the linked issue results in an exception:
`org.hibernate.PropertyAccessException: Could not set value of type [org.hibernate.orm.test.onetoone.singletable.SingleTableOneToOneTest$SubClass1]: 'org.hibernate.orm.test.onetoone.singletable.SingleTableOneToOneTest$Container2.subClass22' (setter)`
The select hibernate issues is:
but this is incomplete, it lacks additional conditions in the where clause, it should be:
Hello , I think it is still not fixed in 6.2.11 when the entity is retrieved using entity graphs. I am attaching a sample project …
Marco Belladelli September 20, 2023 at 7:23 AM
I think the subtype condition should be included in the on clause, or maybe even part of the table reference itself through a subquery, to maintain correct left join semantics. This was previously described e.g. in . See also where we recently changed how subtype restrictions are applied for table groups for similar reasons.
Running the simple
query on the domain model described in the linked issue results in an exception:
`org.hibernate.PropertyAccessException: Could not set value of type [org.hibernate.orm.test.onetoone.singletable.SingleTableOneToOneTest$SubClass1]: 'org.hibernate.orm.test.onetoone.singletable.SingleTableOneToOneTest$Container2.subClass22' (setter)`
The select hibernate issues is:
but this is incomplete, it lacks additional conditions in the where clause, it should be: