Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-16018 (
https://hibernate.atlassian.net/browse/HHH-16018?atlOrigin=eyJpIjoiNzVkMD...
)
Re: ClassCastException on HQL CASE/WHEN w/Entity type - SingleTableEntityPersister vs
BasicValuedMapping (
https://hibernate.atlassian.net/browse/HHH-16018?atlOrigin=eyJpIjoiNzVkMD...
)
The only “bug” here is that we are not throwing a more informative exception. A case
expression requires that the result arms produce a scalar result and an entity is
definitely not a scalar result. The underlying SQL will have to select columns for both
associations anyway. I can be convinced that this can be viewed as a nice new feature, but
at the same time, I don’t see how a case when expression greatly improves anything vs.
retrieving both associations as result and you doing that check in Java code. There are
actually some pretty hard problems here that we would have to handle if we wanted to
support this, like selecting which columns to use for rendering the expression. In a
select item you want to select everything, but in a predicate, you probably want the
FK/PK, but if you use different associations which have different mappings, this is turns
out to become a pretty annoying problem to solve in general. We already have a bunch of
code that tries to handle all possible cases of comparing two entity valued paths and that
is pretty complex already because there are so many cases to consider. I think that
deciding on the columns when even more paths are involved is going to be even messier.
What do you mean by this worked in Hibernate 5? Can you please create a test case that
reproduces this scenario?
(
https://hibernate.atlassian.net/browse/HHH-16018#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16018#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100213- sha1:b01baad )