So I just upgraded from Hibernate 5.6.7 to 6.2.7 with the upgrade to Springboot 3. I have gone through bunch of small changes that have needed to happen with the version just but I am having an issue with a few of my queries what are using JoinType.LEFT, that worked previously but now are not working.
When I look at the query that is being produced by the hibernate code, what used to produce a left outer join is now just producing a straight join.
Hibernate 5
from actions action0_ left outer join location location1_ on action0_.location=location1_.id
left outer join leads lead2_ on action0_.lead_id=lead2_.id
Hibernate 6
from actions a1_0 join location l3_0 on l3_0.id=a1_0.location
join leads l4_0 on l4_0.id=a1_0.lead_id
My entity structure and code didn’t change and the issue I am having with this, is I am not getting results when there is nothing to join to right now, and in this specific call, the action is tied to either a location or a lead, so I get no results now because 1 of them will always be null.
This is the code for the join (works in 5):
from.join(Action_.location, JoinType.LEFT);
from.join(Action_.lead, JoinType.LEFT);
This is the entity relationship:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location", referencedColumnName = "id")
Location location;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "lead_id", referencedColumnName = "id")
Lead lead;
Maybe a change happened that I haven’t found yet that caused this problem, but any insight or help would be great.
Thanks.