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 |