AndreyL (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzYwZmFmN2Q5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16009?atlOrigin=eyJpIjoiNzYwZm...
) HHH-16009 (
https://hibernate.atlassian.net/browse/HHH-16009?atlOrigin=eyJpIjoiNzYwZm...
) jakarta @OrderBy annotation generates a non-transformed column name in the native query
for a composite key's field (
https://hibernate.atlassian.net/browse/HHH-16009?atlOrigin=eyJpIjoiNzYwZm...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Created: 09/Jan/2023 09:38 AM
Environment: Hibernate 6.1.6
Java 17 Priority: Blocker Reporter: AndreyL (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Please, refer to this Repository that contains a project that reproduces the problem:
https://github.com/Andremoniy/hibernate-6-order-by-issue (
https://github.com/Andremoniy/hibernate-6-order-by-issue )
Basically, under certain conditions the column name provided in the OrderBy annotation is
not transformed to the physical name of the column in the databse.
This is a combination of the three different conditions:
* The field used in the OrderBy should be a part of a composite key on the mapped entity.
In our case this is DepartmentId composite key:
public class DepartmentId implements Serializable {
private Company company;
private String departmentCode;
}
* The field used in the OrderBy entity should contain more than a word in its name (if we
rename departmentCode into code , the issue goes away).
* There should be an HQL query that uses LEFT JOIN FETCH on the problematic entity.
@Query("""
SELECT c
FROM Company c
LEFT JOIN FETCH c.departments
WHERE c.name = :name
"""
)
Optional<Company> findCompanyByName(@Param("name") String name);
(
https://hibernate.atlassian.net/browse/HHH-16009#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16009#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:1fa7b87 )