Georgios Andrianakis (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNWE0Yzk4NTk0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16165?atlOrigin=eyJpIjoiNWE0Yz...
) HHH-16165 (
https://hibernate.atlassian.net/browse/HHH-16165?atlOrigin=eyJpIjoiNWE0Yz...
) Incorrect SQL generated when using SELECT DISTINCT and @OrderBy (
https://hibernate.atlassian.net/browse/HHH-16165?atlOrigin=eyJpIjoiNWE0Yz...
)
Issue Type: Bug Affects Versions: 6.2.0.CR2 Assignee: Unassigned Created: 09/Feb/2023
21:45 PM Priority: Major Reporter: Georgios Andrianakis (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
When running Hibernate Reactive’s ManyToManyTest (
https://github.com/hibernate/hibernate-reactive/blob/wip/ORM-6/hibernate-...
) , the test fails with:
java.util.concurrent.CompletionException: org.hibernate.HibernateException:
java.util.concurrent.CompletionException: io.vertx.pgclient.PgException: ERROR: for SELECT
DISTINCT, ORDER BY expressions must appear in select list (42P10)
The problematic part is this (
https://github.com/hibernate/hibernate-reactive/blob/wip/ORM-6/hibernate-...
) which leads to the following generated SQL:
select distinct a1_0.id, b1_0.Author_id, b1_1.id, b1_1.title, a1_0. name
from MTMAuthor a1_0
left join (MTMAuthor_MTMBook b1_0 join MTMBook b1_1 on b1_1.id = b1_0.books_id) on
a1_0.id = b1_0.Author_id
order by b1_0.books_id
The test worked just fine in Hibernate Reactive’s main branch (using ORM 5.5)
A discussion of the issue can also be found here (
https://hibernate.zulipchat.com/#narrow/stream/205413-hibernate-reactive-...
).
(
https://hibernate.atlassian.net/browse/HHH-16165#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16165#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#100215- sha1:a0f3b6a )