Bartlomiej Niemiec (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cdd0b2...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZWFmZTAwZTQx...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15482?atlOrigin=eyJpIjoiZWFmZT...
) HHH-15482 (
https://hibernate.atlassian.net/browse/HHH-15482?atlOrigin=eyJpIjoiZWFmZT...
) CoercionException in criteria simple case statement (
https://hibernate.atlassian.net/browse/HHH-15482?atlOrigin=eyJpIjoiZWFmZT...
)
Issue Type: Bug Affects Versions: 6.1.2 Assignee: Unassigned Attachments:
case_cast_error.zip Components: hibernate-core Created: 06/Sep/2022 02:55 AM Environment:
JDK 17 Priority: Major Reporter: Bartlomiej Niemiec (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cdd0b2...
)
I have the following mappings:
@Entity
@Table(schema = "test" , name = "t_primary" )
public class Primary implements Serializable {
@Id
private int id;
@ManyToOne
@JoinColumn(name = "t_secondary_code" )
private Secondary secondary;
@Column(name = "result_value" )
private Integer resultValue;
// rest of te code
}
@Entity
@Table(schema = "test" , name = "t_secondary" )
public class Secondary implements Serializable {
@Id
private String code;
// rest of the code
}
executing query like this:
CriteriaBuilder cb = em.getCriteriaBuilder();
var query = cb.createTupleQuery();
Root<Primary> root = query.from(Primary.class);
var secondaryJoin = root.join(Primary_.secondary);
query.multiselect(
cb.selectCase(secondaryJoin.get(Secondary_.code))
.when( "a" , root.get(Primary_.resultValue))
.otherwise(cb.nullLiteral( Integer.class)).alias( "value" )
).orderBy(
cb.asc(root.get(Primary_.id))
);
will result in:
org.hibernate.type.descriptor.java.CoercionException: Error coercing value
Caused by: java.lang.NumberFormatException: For input string: "a"
This example works perfectly fine in versions 5.6.X
(
https://hibernate.atlassian.net/browse/HHH-15482#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15482#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#100206- sha1:40f823c )