Simplify TableJoin to only allow the distinction between inner and left joins
This commit is contained in:
parent
1988ffa310
commit
ab954925e4
|
@ -1356,7 +1356,7 @@ public abstract class AbstractEntityPersister
|
|||
);
|
||||
|
||||
return new TableReferenceJoin(
|
||||
determineSubclassTableJoinType(
|
||||
shouldInnerJoinSubclassTable(
|
||||
i,
|
||||
Collections.emptySet()
|
||||
),
|
||||
|
@ -1404,7 +1404,7 @@ public abstract class AbstractEntityPersister
|
|||
lhs,
|
||||
joinTableExpression,
|
||||
sqlAliasBase,
|
||||
determineSubclassTableJoinType( i, Collections.emptySet() ),
|
||||
shouldInnerJoinSubclassTable( i, Collections.emptySet() ),
|
||||
getSubclassTableKeyColumns( i ),
|
||||
sqlExpressionResolver
|
||||
);
|
||||
|
@ -1418,18 +1418,18 @@ public abstract class AbstractEntityPersister
|
|||
TableReference lhs,
|
||||
String joinTableExpression,
|
||||
SqlAliasBase sqlAliasBase,
|
||||
SqlAstJoinType joinType,
|
||||
boolean innerJoin,
|
||||
String[] targetColumns,
|
||||
SqlExpressionResolver sqlExpressionResolver) {
|
||||
final NamedTableReference joinedTableReference = new NamedTableReference(
|
||||
joinTableExpression,
|
||||
sqlAliasBase.generateNewAlias(),
|
||||
joinType != SqlAstJoinType.INNER,
|
||||
!innerJoin,
|
||||
getFactory()
|
||||
);
|
||||
|
||||
return new TableReferenceJoin(
|
||||
joinType,
|
||||
innerJoin,
|
||||
joinedTableReference,
|
||||
generateJoinPredicate(
|
||||
lhs,
|
||||
|
@ -4062,7 +4062,7 @@ public abstract class AbstractEntityPersister
|
|||
return false;
|
||||
}
|
||||
|
||||
protected SqlAstJoinType determineSubclassTableJoinType(
|
||||
protected boolean shouldInnerJoinSubclassTable(
|
||||
int subclassTableNumber,
|
||||
Set<String> treatAsDeclarations) {
|
||||
if ( isClassOrSuperclassJoin( subclassTableNumber ) ) {
|
||||
|
@ -4070,7 +4070,7 @@ public abstract class AbstractEntityPersister
|
|||
&& !isNullableTable( subclassTableNumber );
|
||||
// the table is either this persister's driving table or (one of) its super class persister's driving
|
||||
// tables which can be inner joined as long as the `shouldInnerJoin` condition resolves to true
|
||||
return shouldInnerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT;
|
||||
return shouldInnerJoin;
|
||||
}
|
||||
|
||||
// otherwise we have a subclass table and need to look a little deeper...
|
||||
|
@ -4080,10 +4080,10 @@ public abstract class AbstractEntityPersister
|
|||
// so we give TREAT-AS higher precedence...
|
||||
|
||||
if ( isSubclassTableIndicatedByTreatAsDeclarations( subclassTableNumber, treatAsDeclarations ) ) {
|
||||
return SqlAstJoinType.INNER;
|
||||
return true;
|
||||
}
|
||||
|
||||
return SqlAstJoinType.LEFT;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isSubclassTableIndicatedByTreatAsDeclarations(
|
||||
|
|
|
@ -1346,7 +1346,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
&& sharedSuperclassTables.contains( joinedTableReference.getTableExpression() ) ) {
|
||||
tableReferenceJoins.add(
|
||||
new TableReferenceJoin(
|
||||
SqlAstJoinType.INNER,
|
||||
true,
|
||||
joinedTableReference,
|
||||
oldJoin.getPredicate()
|
||||
)
|
||||
|
|
|
@ -19,25 +19,19 @@ import org.hibernate.sql.ast.tree.predicate.PredicateContainer;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableReferenceJoin implements TableJoin, PredicateContainer {
|
||||
private final SqlAstJoinType sqlAstJoinType;
|
||||
private final boolean innerJoin;
|
||||
private final NamedTableReference joinedTableBinding;
|
||||
private Predicate predicate;
|
||||
|
||||
public TableReferenceJoin(SqlAstJoinType sqlAstJoinType, NamedTableReference joinedTableBinding, Predicate predicate) {
|
||||
this.sqlAstJoinType = sqlAstJoinType == null ? SqlAstJoinType.LEFT : sqlAstJoinType;
|
||||
public TableReferenceJoin(boolean innerJoin, NamedTableReference joinedTableBinding, Predicate predicate) {
|
||||
this.innerJoin = innerJoin;
|
||||
this.joinedTableBinding = joinedTableBinding;
|
||||
this.predicate = predicate;
|
||||
|
||||
// if ( joinType == JoinType.CROSS ) {
|
||||
// if ( predicate != null ) {
|
||||
// throw new IllegalJoinSpecificationException( "Cross join cannot include join predicate" );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlAstJoinType getJoinType() {
|
||||
return sqlAstJoinType;
|
||||
return innerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT;
|
||||
}
|
||||
|
||||
public NamedTableReference getJoinedTableReference() {
|
||||
|
|
Loading…
Reference in New Issue