Bartlomiej Niemiec (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cdd0b2...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTNlYTEzZmVh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16926?atlOrigin=eyJpIjoiYTNlYT...
) HHH-16926 (
https://hibernate.atlassian.net/browse/HHH-16926?atlOrigin=eyJpIjoiYTNlYT...
) AssertionError when sorting by fields of joined entity (
https://hibernate.atlassian.net/browse/HHH-16926?atlOrigin=eyJpIjoiYTNlYT...
)
Issue Type: Bug Affects Versions: 6.2.6 Assignee: Unassigned Attachments: testcase.zip
Components: hibernate-core Created: 12/Jul/2023 01:47 AM Environment: OpenJDK 17 Priority:
Major Reporter: Bartlomiej Niemiec (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5cdd0b2...
)
With entities mapped like this:
@Entity
@Table(schema = "test" , name = "t_primary" )
public class Primary implements Serializable {
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "t_secondary_id" )
private Secondary secondary;
private String name;
// rest of the code
@Entity
@Table(schema = "test" , name = "t_secondary" )
public class Secondary implements Serializable {
@Id
private int id;
private String name;
@Column(name = "second_name" )
private String secondName;
// rest of the code
when you try to execute following query:
CriteriaBuilder cb = em.getCriteriaBuilder();
var query = cb.createQuery(Primary.class);
Root<Primary> root = query.from(Primary.class);
var secondaryJoin = root.join(Primary_.secondary);
query.select(root).orderBy(
cb.asc(secondaryJoin.get(Secondary_.name)),
cb.asc(secondaryJoin.get(Secondary_.secondName))
);
var list = em.createQuery(query).getResultList();
Hibernate throws:
java.lang.AssertionError
at org.hibernate.query.sqm.tree.domain.AbstractSqmPath.copyTo(AbstractSqmPath.java:61)
This example worked in 6.2.5.Final
(
https://hibernate.atlassian.net/browse/HHH-16926#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16926#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#100231- sha1:2d13be9 )