HHH-16438 - Apply some suggestions from Christian's code review
Co-authored-by: Christian Beikov <christian.beikov@gmail.com>
This commit is contained in:
parent
6b21d436ce
commit
85a636c856
|
@ -49,6 +49,7 @@ import org.hibernate.id.CompositeNestedGeneratedValueGenerator;
|
|||
import org.hibernate.id.OptimizableGenerator;
|
||||
import org.hibernate.id.enhanced.Optimizer;
|
||||
import org.hibernate.internal.FilterHelper;
|
||||
import org.hibernate.internal.util.MutableObject;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.internal.util.collections.Stack;
|
||||
import org.hibernate.internal.util.collections.StandardStack;
|
||||
|
@ -3166,7 +3167,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
}
|
||||
|
||||
private TableGroup consumeEntityJoin(SqmEntityJoin<?> sqmJoin, TableGroup lhsTableGroup, boolean transitive) {
|
||||
final List<Predicate> predicates = new ArrayList<>();
|
||||
final MutableObject<Predicate> predicate = new MutableObject<>();
|
||||
final EntityPersister entityDescriptor = resolveEntityPersister( sqmJoin.getReferencedPathSource() );
|
||||
|
||||
final SqlAstJoinType correspondingSqlJoinType = sqmJoin.getSqmJoinType().getCorrespondingSqlJoinType();
|
||||
|
@ -3175,17 +3176,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
sqmJoin.getNavigablePath(),
|
||||
sqmJoin.getExplicitAlias(),
|
||||
null,
|
||||
() -> (predicate) -> {
|
||||
switch ( correspondingSqlJoinType ) {
|
||||
case INNER:
|
||||
case LEFT:
|
||||
case FULL:
|
||||
predicates.add( predicate );
|
||||
break;
|
||||
default:
|
||||
additionalRestrictions = combinePredicates( additionalRestrictions, predicate );
|
||||
}
|
||||
},
|
||||
() -> p -> predicate.set( combinePredicates( predicate.get(), p ) ),
|
||||
this
|
||||
);
|
||||
getFromClauseIndex().register( sqmJoin, tableGroup );
|
||||
|
@ -3194,7 +3185,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
sqmJoin.getNavigablePath(),
|
||||
correspondingSqlJoinType,
|
||||
tableGroup,
|
||||
predicates.size() == 1 ? predicates.get(0) : null
|
||||
predicate.get()
|
||||
);
|
||||
|
||||
// add any additional join restrictions
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.testing.orm.junit.SessionFactory;
|
|||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -102,33 +103,7 @@ public class JoinWithSingleTableInheritanceTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCrossJoinOnSingleTableInheritance(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
s.persist(new ChildEntityA( 11 ));
|
||||
s.persist(new ChildEntityA( 12 ));
|
||||
s.persist(new ChildEntityB( 21 ));
|
||||
RootOne r1 = new RootOne(1);
|
||||
r1.setSomeOtherId( 11 );
|
||||
s.persist( r1 );
|
||||
RootOne r2 = new RootOne(2);
|
||||
r2.setSomeOtherId( 12 );
|
||||
s.persist( r2 );
|
||||
RootOne r3 = new RootOne(3);
|
||||
r3.setSomeOtherId( 21 );
|
||||
s.persist( r3 );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
List<Object[]> l = s.createSelectionQuery( "select r.id, r.someOtherId from RootOne r join ChildEntityA", Object[].class ).list();
|
||||
assertEquals( 6, l.size() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled(value = "HHH-16494")
|
||||
public void testRightJoinOnSingleTableInheritance(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
|
@ -172,6 +147,7 @@ public class JoinWithSingleTableInheritanceTest {
|
|||
|
||||
@Test
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsFullJoin.class)
|
||||
@Disabled(value = "HHH-16494")
|
||||
public void testFullJoinOnSingleTableInheritance(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
|
@ -195,8 +171,8 @@ public class JoinWithSingleTableInheritanceTest {
|
|||
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
List<Object[]> l = s.createSelectionQuery( "select r.id, r.someOtherId from RootOne r full join ChildEntityA ce order by ce.id, r.id", Object[].class ).list();
|
||||
assertEquals( 10, l.size() );
|
||||
List<Object[]> l = s.createSelectionQuery( "select r.id, r.someOtherId from RootOne r full join ChildEntityA ce on ce.id = r.someOtherId order by ce.id, r.id", Object[].class ).list();
|
||||
assertEquals( 7, l.size() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue