[JIRA] (HHH-16856) Hibernate incorrectly does regular JOIN instead of LEFT JOIN when moving from Spring Boot 3.1.0 to 3.1.1
by Sebastiaan van den Broek (JIRA)
Sebastiaan van den Broek ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16856 ( https://hibernate.atlassian.net/browse/HHH-16856?atlOrigin=eyJpIjoiMmE2MD... )
Re: Hibernate incorrectly does regular JOIN instead of LEFT JOIN when moving from Spring Boot 3.1.0 to 3.1.1 ( https://hibernate.atlassian.net/browse/HHH-16856?atlOrigin=eyJpIjoiMmE2MD... )
The query inSpring Boot 3.1.0/Hibernate 6.2.2 is fine:
Hibernate: select a1_0.id,a1_0.created_date,a1_0.db_version,a1_0.expiry_date,a1_0.last_used,a1_0.name,a1_0.project_id,a1_0.public_part,a1_0.role_id,a1_0.secret_key_hash,a1_0.updated_date from api_key a1_0 left join role r1_0 on r1_0.id=a1_0.role_id where a1_0.project_id=? order by r1_0.name offset ? rows fetch first ? rows only
( https://hibernate.atlassian.net/browse/HHH-16856#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16856#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:3bc807d )
1 year, 6 months
[JIRA] (HHH-16856) Hibernate incorrectly does regular JOIN instead of LEFT JOIN when moving from Spring Boot 3.1.0 to 3.1.1
by Sebastiaan van den Broek (JIRA)
Sebastiaan van den Broek ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjgwZDU1MzU5... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16856?atlOrigin=eyJpIjoiMjgwZD... ) HHH-16856 ( https://hibernate.atlassian.net/browse/HHH-16856?atlOrigin=eyJpIjoiMjgwZD... ) Hibernate incorrectly does regular JOIN instead of LEFT JOIN when moving from Spring Boot 3.1.0 to 3.1.1 ( https://hibernate.atlassian.net/browse/HHH-16856?atlOrigin=eyJpIjoiMjgwZD... )
Issue Type: Bug Affects Versions: 6.2.5 Assignee: Unassigned Created: 26/Jun/2023 23:42 PM Environment: Java 17 and 20, Ubuntu and Windows 11. Priority: Major Reporter: Sebastiaan van den Broek ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Repository method defines a LEFT JOIN, as we need to sort on something in role, but it is an optional foreign key.
@Query("""
SELECT ak FROM ApiKey ak
LEFT JOIN ak.role r
WHERE ak.projectId = :projectId
""")
Page<ApiKey> find(@Param("projectId") UUID projectId, Pageable pageable);
Generated SQL creates a regular JOIN now, which means results go missing.
Hibernate: select a1_0.id,a1_0.created_date,a1_0.db_version,a1_0.expiry_date,a1_0.last_used,a1_0.name,a1_0.project_id,a1_0.public_part,a1_0.role_id,a1_0.secret_key_hash,a1_0.updated_date from api_key a1_0 join role r2_0 on r2_0.id=a1_0.role_id where a1_0.project_id=? order by r2_0.name offset ? rows fetch first ? rows only
( https://hibernate.atlassian.net/browse/HHH-16856#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16856#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:3bc807d )
1 year, 6 months