Fetching multiple fields of the same base class with InheritanceType.SINGLE_TABLE throws PropertyAccessException
Description
relates to
Activity
Seong Lee August 16, 2023 at 6:13 PM
Hi Marco, thank you for the update!
I will look out for the new version release(s) and test.
Marco Belladelli August 11, 2023 at 1:16 PMEdited
Hi and . Another similar issue was recently fixed: .
Please let me know if the error persists for you after this change, you can wait for 6.2.8 or 6.3.0 to be released or test using the latest Hibernate snapshot.
Seong Lee August 8, 2023 at 6:41 PMEdited
Hello @Marco Belladelli, I am seeing this exact same error when using a InheritanceType.JOINED
type on the parent. This was working fine on SpringBoot 3.0.6
(Hibernate 6.1.7.Final
)
I am upgrading to SpringBoot 3.1.2
, which uses Hibernate 6.2.6.Final
. I’ve also tried forcing the 6.3.0.CR1
version and still see the error. This is written in Kotlin.
Note: I understand @DiscriminatorColumn is unnecessary for a Joined Inheritance, but this was existing logic I have yet to change.
Marco Belladelli August 2, 2023 at 7:15 AM
Hello , since the fix for was integrated and released in version 6.3.0.CR1 it would be nice if you could test if your issue persists with Hibernate’s latest version.
Marco Belladelli July 13, 2023 at 2:03 PM
Hello , thanks for reporting the issue. From what you’ve described, this seems closely related to , in that you’re trying to (left) join an association to a sub-type entity in an inheritance structure, and expect only the records corresponding to that sub-type to be joined.
To be sure of this, though, we would need to see the complete mapping of you model or, even better, you could provide a simplified reproducer using our test case templates.
Meanwhile, the issue I mentioned has a work in progress fix, you can follow that for any updates.
We are using a single address table with InheritanceType.SINGLE_TABLE and a simple discriminator value:
We are using a query that selects a single case, the customer assigned to the case and the addresses of the customer:
When we used Spring Boot 2.x, the generated SQL contained joins like this:
After switching to Spring Boot 3.x / Hibernate 6.x, the SQL looks like this - the condition on the discriminator column is missing:
An exception is thrown: