Skip to content

Commit e85d204

Browse files
committed
HHH-16885 Hibernate 6.x changes outer to inner join when @entitygraph and @id
1 parent aa0af5a commit e85d204

File tree

4 files changed

+20
-43
lines changed

4 files changed

+20
-43
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractCompositeIdentifierMapping.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ public TableGroupJoin createTableGroupJoin(
125125
boolean fetched,
126126
boolean addsPredicate,
127127
SqlAstCreationState creationState) {
128-
final SqlAstJoinType joinType;
129-
if ( requestedJoinType == null ) {
130-
joinType = SqlAstJoinType.INNER;
131-
}
132-
else {
133-
joinType = requestedJoinType;
134-
}
128+
final SqlAstJoinType joinType = determineSqlJoinType( lhs, requestedJoinType, fetched );
135129
final TableGroup tableGroup = createRootTableGroupJoin(
136130
navigablePath,
137131
lhs,
@@ -294,4 +288,5 @@ public boolean hasPartitionedSelectionMapping() {
294288
public boolean containsTableReference(String tableExpression) {
295289
return entityMapping.containsTableReference( tableExpression );
296290
}
291+
297292
}

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -680,22 +680,6 @@ public TableGroupJoin createTableGroupJoin(
680680
);
681681
}
682682

683-
private SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
684-
final SqlAstJoinType joinType;
685-
if ( requestedJoinType == null ) {
686-
if ( fetched ) {
687-
joinType = getDefaultSqlAstJoinType( lhs );
688-
}
689-
else {
690-
joinType = SqlAstJoinType.INNER;
691-
}
692-
}
693-
else {
694-
joinType = requestedJoinType;
695-
}
696-
return joinType;
697-
}
698-
699683
@Override
700684
public TableGroup createRootTableGroupJoin(
701685
NavigablePath navigablePath,
@@ -707,9 +691,7 @@ public TableGroup createRootTableGroupJoin(
707691
Consumer<Predicate> predicateConsumer,
708692
SqlAstCreationState creationState) {
709693
final CollectionPersister collectionDescriptor = getCollectionDescriptor();
710-
final SqlAstJoinType joinType = requestedJoinType == null
711-
? SqlAstJoinType.INNER
712-
: requestedJoinType;
694+
final SqlAstJoinType joinType = determineSqlJoinType( lhs, requestedJoinType, fetched );
713695
final SqlAliasBase sqlAliasBase = creationState.getSqlAliasBaseGenerator().createSqlAliasBase( getSqlAliasStem() );
714696

715697
final TableGroup tableGroup;
@@ -741,6 +723,7 @@ public TableGroup createRootTableGroupJoin(
741723
return tableGroup;
742724
}
743725

726+
744727
@Override
745728
public void setForeignKeyDescriptor(ForeignKeyDescriptor fkDescriptor) {
746729
this.fkDescriptor = fkDescriptor;

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import java.util.Arrays;
1010
import java.util.HashSet;
11-
import java.util.Iterator;
1211
import java.util.List;
1312
import java.util.Set;
1413
import java.util.function.BiConsumer;
@@ -1984,22 +1983,6 @@ public TableGroupJoin createTableGroupJoin(
19841983
return join;
19851984
}
19861985

1987-
private SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
1988-
final SqlAstJoinType joinType;
1989-
if ( requestedJoinType == null ) {
1990-
if ( fetched ) {
1991-
joinType = getDefaultSqlAstJoinType( lhs );
1992-
}
1993-
else {
1994-
joinType = SqlAstJoinType.INNER;
1995-
}
1996-
}
1997-
else {
1998-
joinType = requestedJoinType;
1999-
}
2000-
return joinType;
2001-
}
2002-
20031986
@Override
20041987
public LazyTableGroup createRootTableGroupJoin(
20051988
NavigablePath navigablePath,

hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroupJoinProducer.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,20 @@ TableGroup createRootTableGroupJoin(
7676
boolean fetched,
7777
Consumer<Predicate> predicateConsumer,
7878
SqlAstCreationState creationState);
79+
80+
default SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
81+
final SqlAstJoinType joinType;
82+
if ( requestedJoinType == null ) {
83+
if ( fetched ) {
84+
joinType = getDefaultSqlAstJoinType( lhs );
85+
}
86+
else {
87+
joinType = SqlAstJoinType.INNER;
88+
}
89+
}
90+
else {
91+
joinType = requestedJoinType;
92+
}
93+
return joinType;
94+
}
7995
}

0 commit comments

Comments
 (0)