Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) *commented* on HHH-17042 (
https://hibernate.atlassian.net/browse/HHH-17042?atlOrigin=eyJpIjoiODZjY2...
)
Re: JoinType Doesn't Work (Using JoinType.LEFT) (
https://hibernate.atlassian.net/browse/HHH-17042?atlOrigin=eyJpIjoiODZjY2...
)
Hello Brian Leierzapf (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ee5183...
) , thank you for reporting the issue and providing a reproducer.
Looking at you’re example I believe the problem is how you’re using the Criteria API. It’s
true that you’re specifying JoinType.LEFT when calling the join method, but you’re
ignoring the return value of that method - which is, the left joined association path -
and later on calling e.g. from.get( Action_.location ).get( ... ). The JPA spec, in
chapter 6.5.5 (
https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spe...
) , explicitly defines path navigation (i.e. the path.get() method) always has “inner
join” semantics - that’s why in the resulting query you’re seeing inner joins.
You should instead do something like:
final Join<Action, Location> locationJoin = from.join( "location" ,
JoinType.LEFT );
...
predicates.add( cb.isTrue( locationJoin.get( "active" ) );
This probably used to work by chance in 5 since the get method reused the existing left
join, but you should switch to using the correct path instances.
(
https://hibernate.atlassian.net/browse/HHH-17042#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-17042#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#100234- sha1:90f5128 )