Kurt Gollhardt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjY3YzJmYzE2...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16018?atlOrigin=eyJpIjoiNjY3Yz...
) HHH-16018 (
https://hibernate.atlassian.net/browse/HHH-16018?atlOrigin=eyJpIjoiNjY3Yz...
) ClassCastException on HQL CASE/WHEN w/Entity type - SingleTableEntityPersister vs
BasicValuedMapping (
https://hibernate.atlassian.net/browse/HHH-16018?atlOrigin=eyJpIjoiNjY3Yz...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Components: query-hql
Created: 10/Jan/2023 17:38 PM Priority: Major Reporter: Kurt Gollhardt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
The CaseSearchedExpression constructor casts the type parameter to BasicValuedMapping.
This gets a ClassCastException when the type is a SingleTableEntityPersister. For
example:
select case when true then customer1 else customer2 end from TransactRecord
@Entity(name = "TransactRecord" )
class TransactRecord {
@JoinColumn(name = "CUSTOMER1" , nullable = true )
@ManyToOne(fetch = FetchType.EAGER)
@LazyToOne(LazyToOneOption.FALSE)
private CustomerRecord customer1;
@JoinColumn(name = "CUSTOMER2" , nullable = true )
@ManyToOne(fetch = FetchType.EAGER)
@LazyToOne(LazyToOneOption.FALSE)
private CustomerRecord customer2;
}
@Entity(name = "CustomerRecord" )
class CustomerRecord {
// ...
}
This worked in 5.4.22.
Workaround: The Simple Case expression does not have this problem. For example:
select case property when value then customer1 else customer2 end from TransactRecord
(
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:cca7326 )