Skip to content

Commit 24f75fb

Browse files
committed
HHH-15613 remove lateral roots from criteria API
1 parent 3357d1e commit 24f75fb

File tree

8 files changed

+16
-59
lines changed

8 files changed

+16
-59
lines changed

hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDerivedFrom.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,5 @@ public interface JpaDerivedFrom<T> extends JpaFrom<T,T> {
1818
* The subquery part for this derived from node.
1919
*/
2020
JpaSubQuery<T> getQueryPart();
21-
22-
/**
23-
* Specifies whether the subquery part can access previous from node aliases.
24-
* Normally, subqueries in the from clause are unable to access other from nodes,
25-
* but when specifying them as lateral, they are allowed to do so.
26-
* Refer to the SQL standard definition of LATERAL for more details.
27-
*/
28-
boolean isLateral();
21+
2922
}

hibernate-core/src/main/java/org/hibernate/query/criteria/JpaDerivedJoin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@
1515
@Incubating
1616
public interface JpaDerivedJoin<T> extends JpaDerivedFrom<T>, SqmQualifiedJoin<T,T>, JpaJoinedFrom<T,T> {
1717

18+
/**
19+
* Specifies whether the subquery part can access previous from node aliases.
20+
* Normally, subqueries in the from clause are unable to access other from nodes,
21+
* but when specifying them as lateral, they are allowed to do so.
22+
* Refer to the SQL standard definition of LATERAL for more details.
23+
*/
24+
boolean isLateral();
25+
1826
}

hibernate-core/src/main/java/org/hibernate/query/criteria/JpaSelectCriteria.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,6 @@ public interface JpaSelectCriteria<T> extends AbstractQuery<T>, JpaCriteriaBase
3838
*/
3939
<X> JpaDerivedRoot<X> from(Subquery<X> subquery);
4040

41-
/**
42-
* Create and add a query root corresponding to the given lateral subquery,
43-
* forming a cartesian product with any existing roots.
44-
*
45-
* @param subquery the subquery
46-
* @return query root corresponding to the given subquery
47-
*/
48-
<X> JpaDerivedRoot<X> fromLateral(Subquery<X> subquery);
49-
50-
/**
51-
* Create and add a query root corresponding to the given subquery,
52-
* forming a cartesian product with any existing roots.
53-
* If the subquery is marked as lateral, it may access previous from elements.
54-
*
55-
* @param subquery the subquery
56-
* @param lateral whether to allow access to previous from elements in the subquery
57-
* @return query root corresponding to the given subquery
58-
*/
59-
<X> JpaDerivedRoot<X> from(Subquery<X> subquery, boolean lateral);
60-
6141
@Override
6242
JpaSelectCriteria<T> distinct(boolean distinct);
6343

hibernate-core/src/main/java/org/hibernate/query/hql/internal/QuerySplitter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ public SqmDerivedRoot<?> visitRootDerived(SqmDerivedRoot<?> sqmRoot) {
400400
}
401401
final SqmDerivedRoot<?> copy = new SqmDerivedRoot<>(
402402
(SqmSubQuery<?>) sqmRoot.getQueryPart().accept( this ),
403-
sqmRoot.getExplicitAlias(),
404-
sqmRoot.isLateral()
403+
sqmRoot.getExplicitAlias()
405404
);
406405
getProcessingStateStack().getCurrent().getPathRegistry().register( copy );
407406
sqmFromCopyMap.put( sqmRoot, copy );

hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,10 +1661,8 @@ public SqmRoot<?> visitRootSubquery(HqlParser.RootSubqueryContext ctx) {
16611661
StrictJpaComplianceViolation.Type.FROM_SUBQUERY
16621662
);
16631663
}
1664-
final ParseTree firstChild = ctx.getChild( 0 );
1665-
final boolean lateral = ( (TerminalNode) firstChild ).getSymbol().getType() == HqlParser.LATERAL;
1666-
final int subqueryIndex = lateral ? 2 : 1;
1667-
final SqmSubQuery<?> subQuery = (SqmSubQuery<?>) ctx.getChild( subqueryIndex ).accept( this );
1664+
1665+
final SqmSubQuery<?> subQuery = (SqmSubQuery<?>) ctx.getChild(1).accept( this );
16681666

16691667
final ParseTree lastChild = ctx.getChild( ctx.getChildCount() - 1 );
16701668
final HqlParser.VariableContext identificationVariableDefContext;
@@ -1680,7 +1678,7 @@ public SqmRoot<?> visitRootSubquery(HqlParser.RootSubqueryContext ctx) {
16801678

16811679
final SqmCreationProcessingState processingState = processingStateStack.getCurrent();
16821680
final SqmPathRegistry pathRegistry = processingState.getPathRegistry();
1683-
final SqmRoot<?> sqmRoot = new SqmDerivedRoot<>( subQuery, alias, lateral );
1681+
final SqmRoot<?> sqmRoot = new SqmDerivedRoot<>( subQuery, alias );
16841682

16851683
pathRegistry.register( sqmRoot );
16861684

hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ protected void consumeFromClauseRoot(SqmRoot<?> sqmRoot) {
25622562
identifierVariable,
25632563
columnNames,
25642564
tableGroupProducer.getCompatibleTableExpressions(),
2565-
derivedRoot.isLateral(),
2565+
false,
25662566
true,
25672567
creationContext.getSessionFactory()
25682568
);

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmDerivedRoot.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,13 @@
2828
public class SqmDerivedRoot<T> extends SqmRoot<T> implements JpaDerivedRoot<T> {
2929

3030
private final SqmSubQuery<T> subQuery;
31-
private final boolean lateral;
3231

3332
public SqmDerivedRoot(
3433
SqmSubQuery<T> subQuery,
35-
String alias,
36-
boolean lateral) {
34+
String alias) {
3735
this(
3836
SqmCreationHelper.buildRootNavigablePath( "<<derived>>", alias ),
3937
subQuery,
40-
lateral,
4138
new AnonymousTupleType<>( subQuery ),
4239
alias
4340
);
@@ -46,7 +43,6 @@ public SqmDerivedRoot(
4643
protected SqmDerivedRoot(
4744
NavigablePath navigablePath,
4845
SqmSubQuery<T> subQuery,
49-
boolean lateral,
5046
SqmPathSource<T> pathSource,
5147
String alias) {
5248
super(
@@ -57,7 +53,6 @@ protected SqmDerivedRoot(
5753
subQuery.nodeBuilder()
5854
);
5955
this.subQuery = subQuery;
60-
this.lateral = lateral;
6156
}
6257

6358
@Override
@@ -71,7 +66,6 @@ public SqmDerivedRoot<T> copy(SqmCopyContext context) {
7166
new SqmDerivedRoot<>(
7267
getNavigablePath(),
7368
getQueryPart().copy( context ),
74-
isLateral(),
7569
getReferencedPathSource(),
7670
getExplicitAlias()
7771
)
@@ -85,11 +79,6 @@ public SqmSubQuery<T> getQueryPart() {
8579
return subQuery;
8680
}
8781

88-
@Override
89-
public boolean isLateral() {
90-
return lateral;
91-
}
92-
9382
@Override
9483
public <X> X accept(SemanticQueryWalker<X> walker) {
9584
return walker.visitRootDerived( this );

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/AbstractSqmSelectQuery.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,8 @@ public <X> SqmRoot<X> from(Class<X> entityClass) {
143143

144144
@Override
145145
public <X> SqmDerivedRoot<X> from(Subquery<X> subquery) {
146-
return from( subquery, false );
147-
}
148-
149-
@Override
150-
public <X> SqmDerivedRoot<X> fromLateral(Subquery<X> subquery) {
151-
return from( subquery, true );
152-
}
153-
154-
@Override
155-
public <X> SqmDerivedRoot<X> from(Subquery<X> subquery, boolean lateral) {
156146
validateComplianceFromSubQuery();
157-
final SqmDerivedRoot<X> root = new SqmDerivedRoot<>( (SqmSubQuery<X>) subquery, null, lateral );
147+
final SqmDerivedRoot<X> root = new SqmDerivedRoot<>( (SqmSubQuery<X>) subquery, null );
158148
addRoot( root );
159149
return root;
160150
}

0 commit comments

Comments
 (0)