HHH-16885 Hibernate 6.x changes outer to inner join when @EntityGraph and @Id
This commit is contained in:
parent
aa0af5a30d
commit
e85d2040c2
|
@ -125,13 +125,7 @@ public abstract class AbstractCompositeIdentifierMapping
|
||||||
boolean fetched,
|
boolean fetched,
|
||||||
boolean addsPredicate,
|
boolean addsPredicate,
|
||||||
SqlAstCreationState creationState) {
|
SqlAstCreationState creationState) {
|
||||||
final SqlAstJoinType joinType;
|
final SqlAstJoinType joinType = determineSqlJoinType( lhs, requestedJoinType, fetched );
|
||||||
if ( requestedJoinType == null ) {
|
|
||||||
joinType = SqlAstJoinType.INNER;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
joinType = requestedJoinType;
|
|
||||||
}
|
|
||||||
final TableGroup tableGroup = createRootTableGroupJoin(
|
final TableGroup tableGroup = createRootTableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
lhs,
|
lhs,
|
||||||
|
@ -294,4 +288,5 @@ public abstract class AbstractCompositeIdentifierMapping
|
||||||
public boolean containsTableReference(String tableExpression) {
|
public boolean containsTableReference(String tableExpression) {
|
||||||
return entityMapping.containsTableReference( tableExpression );
|
return entityMapping.containsTableReference( tableExpression );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,22 +680,6 @@ public class PluralAttributeMappingImpl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
|
|
||||||
final SqlAstJoinType joinType;
|
|
||||||
if ( requestedJoinType == null ) {
|
|
||||||
if ( fetched ) {
|
|
||||||
joinType = getDefaultSqlAstJoinType( lhs );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
joinType = SqlAstJoinType.INNER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
joinType = requestedJoinType;
|
|
||||||
}
|
|
||||||
return joinType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableGroup createRootTableGroupJoin(
|
public TableGroup createRootTableGroupJoin(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
|
@ -707,9 +691,7 @@ public class PluralAttributeMappingImpl
|
||||||
Consumer<Predicate> predicateConsumer,
|
Consumer<Predicate> predicateConsumer,
|
||||||
SqlAstCreationState creationState) {
|
SqlAstCreationState creationState) {
|
||||||
final CollectionPersister collectionDescriptor = getCollectionDescriptor();
|
final CollectionPersister collectionDescriptor = getCollectionDescriptor();
|
||||||
final SqlAstJoinType joinType = requestedJoinType == null
|
final SqlAstJoinType joinType = determineSqlJoinType( lhs, requestedJoinType, fetched );
|
||||||
? SqlAstJoinType.INNER
|
|
||||||
: requestedJoinType;
|
|
||||||
final SqlAliasBase sqlAliasBase = creationState.getSqlAliasBaseGenerator().createSqlAliasBase( getSqlAliasStem() );
|
final SqlAliasBase sqlAliasBase = creationState.getSqlAliasBaseGenerator().createSqlAliasBase( getSqlAliasStem() );
|
||||||
|
|
||||||
final TableGroup tableGroup;
|
final TableGroup tableGroup;
|
||||||
|
@ -741,6 +723,7 @@ public class PluralAttributeMappingImpl
|
||||||
return tableGroup;
|
return tableGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setForeignKeyDescriptor(ForeignKeyDescriptor fkDescriptor) {
|
public void setForeignKeyDescriptor(ForeignKeyDescriptor fkDescriptor) {
|
||||||
this.fkDescriptor = fkDescriptor;
|
this.fkDescriptor = fkDescriptor;
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.metamodel.mapping.internal;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
@ -1984,22 +1983,6 @@ public class ToOneAttributeMapping
|
||||||
return join;
|
return join;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
|
|
||||||
final SqlAstJoinType joinType;
|
|
||||||
if ( requestedJoinType == null ) {
|
|
||||||
if ( fetched ) {
|
|
||||||
joinType = getDefaultSqlAstJoinType( lhs );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
joinType = SqlAstJoinType.INNER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
joinType = requestedJoinType;
|
|
||||||
}
|
|
||||||
return joinType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LazyTableGroup createRootTableGroupJoin(
|
public LazyTableGroup createRootTableGroupJoin(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
|
|
|
@ -76,4 +76,20 @@ public interface TableGroupJoinProducer extends TableGroupProducer {
|
||||||
boolean fetched,
|
boolean fetched,
|
||||||
Consumer<Predicate> predicateConsumer,
|
Consumer<Predicate> predicateConsumer,
|
||||||
SqlAstCreationState creationState);
|
SqlAstCreationState creationState);
|
||||||
|
|
||||||
|
default SqlAstJoinType determineSqlJoinType(TableGroup lhs, SqlAstJoinType requestedJoinType, boolean fetched) {
|
||||||
|
final SqlAstJoinType joinType;
|
||||||
|
if ( requestedJoinType == null ) {
|
||||||
|
if ( fetched ) {
|
||||||
|
joinType = getDefaultSqlAstJoinType( lhs );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
joinType = SqlAstJoinType.INNER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
joinType = requestedJoinType;
|
||||||
|
}
|
||||||
|
return joinType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue