rename some grammar rules and add documentation
I want this to be readable to users
This commit is contained in:
parent
9c7d39abf1
commit
008455bc0c
File diff suppressed because it is too large
Load Diff
|
@ -391,8 +391,8 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
identificationVariable = applyJpaCompliance(
|
identificationVariable = applyJpaCompliance(
|
||||||
visitIdentificationVariableDef(
|
visitVariable(
|
||||||
(HqlParser.IdentificationVariableDefContext) dmlTargetContext.getChild( 1 )
|
(HqlParser.VariableContext) dmlTargetContext.getChild( 1 )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -447,8 +447,8 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
processingStateStack.push( stateFieldsProcessingState );
|
processingStateStack.push( stateFieldsProcessingState );
|
||||||
try {
|
try {
|
||||||
for ( HqlParser.DotIdentifierSequenceContext stateFieldCtx : targetFieldsSpecContext.dotIdentifierSequence() ) {
|
for ( HqlParser.SimplePathContext stateFieldCtx : targetFieldsSpecContext.simplePath() ) {
|
||||||
final SqmPath<?> stateField = (SqmPath<?>) visitDotIdentifierSequence( stateFieldCtx );
|
final SqmPath<?> stateField = (SqmPath<?>) visitSimplePath( stateFieldCtx );
|
||||||
// todo : validate each resolved stateField...
|
// todo : validate each resolved stateField...
|
||||||
insertStatement.addInsertTargetStateField( stateField );
|
insertStatement.addInsertTargetStateField( stateField );
|
||||||
}
|
}
|
||||||
|
@ -486,8 +486,8 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
insertStatement.getValuesList().add( sqmValues );
|
insertStatement.getValuesList().add( sqmValues );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( HqlParser.DotIdentifierSequenceContext stateFieldCtx : targetFieldsSpecContext.dotIdentifierSequence() ) {
|
for ( HqlParser.SimplePathContext stateFieldCtx : targetFieldsSpecContext.simplePath() ) {
|
||||||
final SqmPath<?> stateField = (SqmPath<?>) visitDotIdentifierSequence( stateFieldCtx );
|
final SqmPath<?> stateField = (SqmPath<?>) visitSimplePath( stateFieldCtx );
|
||||||
// todo : validate each resolved stateField...
|
// todo : validate each resolved stateField...
|
||||||
insertStatement.addInsertTargetStateField( stateField );
|
insertStatement.addInsertTargetStateField( stateField );
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
if ( subCtx instanceof HqlParser.AssignmentContext ) {
|
if ( subCtx instanceof HqlParser.AssignmentContext ) {
|
||||||
final HqlParser.AssignmentContext assignmentContext = (HqlParser.AssignmentContext) subCtx;
|
final HqlParser.AssignmentContext assignmentContext = (HqlParser.AssignmentContext) subCtx;
|
||||||
updateStatement.applyAssignment(
|
updateStatement.applyAssignment(
|
||||||
consumeDomainPath( (HqlParser.DotIdentifierSequenceContext) assignmentContext.getChild( 0 ) ),
|
consumeDomainPath( (HqlParser.SimplePathContext) assignmentContext.getChild( 0 ) ),
|
||||||
(SqmExpression<?>) assignmentContext.getChild( 2 ).accept( this )
|
(SqmExpression<?>) assignmentContext.getChild( 2 ).accept( this )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -890,7 +890,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resultIdentifier = applyJpaCompliance(
|
resultIdentifier = applyJpaCompliance(
|
||||||
visitIdentificationVariableDef( (HqlParser.IdentificationVariableDefContext) ctx.getChild( 1 ) )
|
visitVariable( (HqlParser.VariableContext) ctx.getChild( 1 ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final SqmSelectableNode<?> selectableNode = visitSelectableNode( ctx );
|
final SqmSelectableNode<?> selectableNode = visitSelectableNode( ctx );
|
||||||
|
@ -946,10 +946,10 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmDynamicInstantiation<?> visitDynamicInstantiation(HqlParser.DynamicInstantiationContext ctx) {
|
public SqmDynamicInstantiation<?> visitInstantiation(HqlParser.InstantiationContext ctx) {
|
||||||
final SqmDynamicInstantiation<?> dynamicInstantiation;
|
final SqmDynamicInstantiation<?> dynamicInstantiation;
|
||||||
final ParseTree instantiationTarget = ctx.dynamicInstantiationTarget().getChild( 0 );
|
final ParseTree instantiationTarget = ctx.instantiationTarget().getChild( 0 );
|
||||||
if ( instantiationTarget instanceof HqlParser.DotIdentifierSequenceContext ) {
|
if ( instantiationTarget instanceof HqlParser.SimplePathContext ) {
|
||||||
final String className = instantiationTarget.getText();
|
final String className = instantiationTarget.getText();
|
||||||
try {
|
try {
|
||||||
final JavaType<?> jtd = resolveInstantiationTargetJtd( className );
|
final JavaType<?> jtd = resolveInstantiationTargetJtd( className );
|
||||||
|
@ -982,8 +982,8 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( HqlParser.DynamicInstantiationArgContext arg : ctx.dynamicInstantiationArgs().dynamicInstantiationArg() ) {
|
for ( HqlParser.InstantiationArgumentContext arg : ctx.instantiationArguments().instantiationArgument() ) {
|
||||||
dynamicInstantiation.addArgument( visitDynamicInstantiationArg( arg ) );
|
dynamicInstantiation.addArgument( visitInstantiationArgument( arg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return dynamicInstantiation;
|
return dynamicInstantiation;
|
||||||
|
@ -1002,10 +1002,10 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmDynamicInstantiationArgument<?> visitDynamicInstantiationArg(HqlParser.DynamicInstantiationArgContext ctx) {
|
public SqmDynamicInstantiationArgument<?> visitInstantiationArgument(HqlParser.InstantiationArgumentContext ctx) {
|
||||||
final String alias;
|
final String alias;
|
||||||
if ( ctx.getChildCount() > 1 ) {
|
if ( ctx.getChildCount() > 1 ) {
|
||||||
alias = visitIdentificationVariableDef( (HqlParser.IdentificationVariableDefContext) ctx.getChild( ctx.getChildCount() - 1 ) );
|
alias = visitVariable( (HqlParser.VariableContext) ctx.getChild( ctx.getChildCount() - 1 ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alias = null;
|
alias = null;
|
||||||
|
@ -1148,7 +1148,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
int nextIndex = 1;
|
int nextIndex = 1;
|
||||||
if ( nextIndex < ctx.getChildCount() ) {
|
if ( nextIndex < ctx.getChildCount() ) {
|
||||||
ParseTree parseTree = ctx.getChild( nextIndex );
|
ParseTree parseTree = ctx.getChild( nextIndex );
|
||||||
if ( parseTree instanceof HqlParser.OrderingSpecificationContext ) {
|
if ( parseTree instanceof HqlParser.SortDirectionContext ) {
|
||||||
switch ( ( (TerminalNode) parseTree.getChild( 0 ) ).getSymbol().getType() ) {
|
switch ( ( (TerminalNode) parseTree.getChild( 0 ) ).getSymbol().getType() ) {
|
||||||
case HqlParser.ASC:
|
case HqlParser.ASC:
|
||||||
sortOrder = SortOrder.ASCENDING;
|
sortOrder = SortOrder.ASCENDING;
|
||||||
|
@ -1386,8 +1386,8 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
fromClause = new SqmFromClause( estimatedSize );
|
fromClause = new SqmFromClause( estimatedSize );
|
||||||
for ( int i = 0; i < size; i++ ) {
|
for ( int i = 0; i < size; i++ ) {
|
||||||
final ParseTree parseTree = parserFromClause.getChild( i );
|
final ParseTree parseTree = parserFromClause.getChild( i );
|
||||||
if ( parseTree instanceof HqlParser.FromClauseSpaceContext ) {
|
if ( parseTree instanceof HqlParser.EntityWithJoinsContext ) {
|
||||||
fromClause.addRoot( visitFromClauseSpace( (HqlParser.FromClauseSpaceContext) parseTree ) );
|
fromClause.addRoot( visitEntityWithJoins( (HqlParser.EntityWithJoinsContext) parseTree ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1395,16 +1395,16 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmRoot<?> visitFromClauseSpace(HqlParser.FromClauseSpaceContext parserSpace) {
|
public SqmRoot<?> visitEntityWithJoins(HqlParser.EntityWithJoinsContext parserSpace) {
|
||||||
final SqmRoot<?> sqmRoot = visitPathRoot( (HqlParser.PathRootContext) parserSpace.getChild( 0 ) );
|
final SqmRoot<?> sqmRoot = visitRootEntity( (HqlParser.RootEntityContext) parserSpace.getChild( 0 ) );
|
||||||
final int size = parserSpace.getChildCount();
|
final int size = parserSpace.getChildCount();
|
||||||
for ( int i = 1; i < size; i++ ) {
|
for ( int i = 1; i < size; i++ ) {
|
||||||
final ParseTree parseTree = parserSpace.getChild( i );
|
final ParseTree parseTree = parserSpace.getChild( i );
|
||||||
if ( parseTree instanceof HqlParser.CrossJoinContext ) {
|
if ( parseTree instanceof HqlParser.CrossJoinContext ) {
|
||||||
consumeCrossJoin( (HqlParser.CrossJoinContext) parseTree, sqmRoot );
|
consumeCrossJoin( (HqlParser.CrossJoinContext) parseTree, sqmRoot );
|
||||||
}
|
}
|
||||||
else if ( parseTree instanceof HqlParser.QualifiedJoinContext ) {
|
else if ( parseTree instanceof HqlParser.JoinContext ) {
|
||||||
consumeQualifiedJoin( (HqlParser.QualifiedJoinContext) parseTree, sqmRoot );
|
consumeJoin( (HqlParser.JoinContext) parseTree, sqmRoot );
|
||||||
}
|
}
|
||||||
else if ( parseTree instanceof HqlParser.JpaCollectionJoinContext ) {
|
else if ( parseTree instanceof HqlParser.JpaCollectionJoinContext ) {
|
||||||
consumeJpaCollectionJoin( (HqlParser.JpaCollectionJoinContext) parseTree, sqmRoot );
|
consumeJpaCollectionJoin( (HqlParser.JpaCollectionJoinContext) parseTree, sqmRoot );
|
||||||
|
@ -1416,7 +1416,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||||
public SqmRoot<?> visitPathRoot(HqlParser.PathRootContext ctx) {
|
public SqmRoot<?> visitRootEntity(HqlParser.RootEntityContext ctx) {
|
||||||
final HqlParser.EntityNameContext entityNameContext = (HqlParser.EntityNameContext) ctx.getChild( 0 );
|
final HqlParser.EntityNameContext entityNameContext = (HqlParser.EntityNameContext) ctx.getChild( 0 );
|
||||||
final List<ParseTree> entityNameParseTreeChildren = entityNameContext.children;
|
final List<ParseTree> entityNameParseTreeChildren = entityNameContext.children;
|
||||||
final String name = getEntityName( entityNameContext );
|
final String name = getEntityName( entityNameContext );
|
||||||
|
@ -1426,15 +1426,15 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
.getJpaMetamodel()
|
.getJpaMetamodel()
|
||||||
.getHqlEntityReference( name );
|
.getHqlEntityReference( name );
|
||||||
|
|
||||||
final HqlParser.IdentificationVariableDefContext identificationVariableDefContext;
|
final HqlParser.VariableContext identificationVariableDefContext;
|
||||||
if ( ctx.getChildCount() > 1 ) {
|
if ( ctx.getChildCount() > 1 ) {
|
||||||
identificationVariableDefContext = (HqlParser.IdentificationVariableDefContext) ctx.getChild( 1 );
|
identificationVariableDefContext = (HqlParser.VariableContext) ctx.getChild( 1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
identificationVariableDefContext = null;
|
identificationVariableDefContext = null;
|
||||||
}
|
}
|
||||||
final String alias = applyJpaCompliance(
|
final String alias = applyJpaCompliance(
|
||||||
visitIdentificationVariableDef( identificationVariableDefContext )
|
visitVariable( identificationVariableDefContext )
|
||||||
);
|
);
|
||||||
|
|
||||||
final SqmCreationProcessingState processingState = processingStateStack.getCurrent();
|
final SqmCreationProcessingState processingState = processingStateStack.getCurrent();
|
||||||
|
@ -1502,7 +1502,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String visitIdentificationVariableDef(HqlParser.IdentificationVariableDefContext ctx) {
|
public String visitVariable(HqlParser.VariableContext ctx) {
|
||||||
if ( ctx == null ) {
|
if ( ctx == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1554,7 +1554,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void consumeCrossJoin(HqlParser.CrossJoinContext parserJoin, SqmRoot<T> sqmRoot) {
|
private <T> void consumeCrossJoin(HqlParser.CrossJoinContext parserJoin, SqmRoot<T> sqmRoot) {
|
||||||
final HqlParser.PathRootContext pathRootContext = (HqlParser.PathRootContext) parserJoin.getChild( 2 );
|
final HqlParser.RootEntityContext pathRootContext = (HqlParser.RootEntityContext) parserJoin.getChild( 2 );
|
||||||
final HqlParser.EntityNameContext entityNameContext = (HqlParser.EntityNameContext) pathRootContext.getChild( 0 );
|
final HqlParser.EntityNameContext entityNameContext = (HqlParser.EntityNameContext) pathRootContext.getChild( 0 );
|
||||||
final String name = getEntityName( entityNameContext );
|
final String name = getEntityName( entityNameContext );
|
||||||
|
|
||||||
|
@ -1566,16 +1566,16 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
if ( entityDescriptor instanceof SqmPolymorphicRootDescriptor ) {
|
if ( entityDescriptor instanceof SqmPolymorphicRootDescriptor ) {
|
||||||
throw new SemanticException( "Unmapped polymorphic reference cannot be used as a CROSS JOIN target" );
|
throw new SemanticException( "Unmapped polymorphic reference cannot be used as a CROSS JOIN target" );
|
||||||
}
|
}
|
||||||
final HqlParser.IdentificationVariableDefContext identificationVariableDefContext;
|
final HqlParser.VariableContext identificationVariableDefContext;
|
||||||
if ( pathRootContext.getChildCount() > 1 ) {
|
if ( pathRootContext.getChildCount() > 1 ) {
|
||||||
identificationVariableDefContext = (HqlParser.IdentificationVariableDefContext) pathRootContext.getChild( 1 );
|
identificationVariableDefContext = (HqlParser.VariableContext) pathRootContext.getChild( 1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
identificationVariableDefContext = null;
|
identificationVariableDefContext = null;
|
||||||
}
|
}
|
||||||
final SqmCrossJoin<T> join = new SqmCrossJoin<>(
|
final SqmCrossJoin<T> join = new SqmCrossJoin<>(
|
||||||
entityDescriptor,
|
entityDescriptor,
|
||||||
visitIdentificationVariableDef( identificationVariableDefContext ),
|
visitVariable( identificationVariableDefContext ),
|
||||||
sqmRoot
|
sqmRoot
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1586,15 +1586,15 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final SqmQualifiedJoin<?, ?> visitQualifiedJoin(HqlParser.QualifiedJoinContext parserJoin) {
|
public final SqmJoin<?, ?> visitJoin(HqlParser.JoinContext parserJoin) {
|
||||||
throw new UnsupportedOperationException( "Unexpected call to #visitQualifiedJoin, see #consumeQualifiedJoin" );
|
throw new UnsupportedOperationException( "Unexpected call to #visitJoin, see #consumeJoin" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
protected <X> void consumeQualifiedJoin(HqlParser.QualifiedJoinContext parserJoin, SqmRoot<X> sqmRoot) {
|
protected <X> void consumeJoin(HqlParser.JoinContext parserJoin, SqmRoot<X> sqmRoot) {
|
||||||
final SqmJoinType joinType;
|
final SqmJoinType joinType;
|
||||||
final int firstJoinTypeSymbolType;
|
final int firstJoinTypeSymbolType;
|
||||||
if ( parserJoin.getChild( 0 ) instanceof HqlParser.JoinTypeQualifierContext
|
if ( parserJoin.getChild( 0 ) instanceof HqlParser.JoinTypeContext
|
||||||
&& parserJoin.getChild( 0 ).getChildCount() != 0 ) {
|
&& parserJoin.getChild( 0 ).getChildCount() != 0 ) {
|
||||||
firstJoinTypeSymbolType = ( (TerminalNode) parserJoin.getChild( 0 ).getChild( 0 ) ).getSymbol().getType();
|
firstJoinTypeSymbolType = ( (TerminalNode) parserJoin.getChild( 0 ).getChild( 0 ) ).getSymbol().getType();
|
||||||
}
|
}
|
||||||
|
@ -1618,15 +1618,15 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
final HqlParser.QualifiedJoinRhsContext qualifiedJoinRhsContext = parserJoin.qualifiedJoinRhs();
|
final HqlParser.JoinPathContext qualifiedJoinPathContext = parserJoin.joinPath();
|
||||||
final HqlParser.IdentificationVariableDefContext identificationVariableDefContext;
|
final HqlParser.VariableContext identificationVariableDefContext;
|
||||||
if ( qualifiedJoinRhsContext.getChildCount() > 1 ) {
|
if ( qualifiedJoinPathContext.getChildCount() > 1 ) {
|
||||||
identificationVariableDefContext = (HqlParser.IdentificationVariableDefContext) qualifiedJoinRhsContext.getChild( 1 );
|
identificationVariableDefContext = (HqlParser.VariableContext) qualifiedJoinPathContext.getChild( 1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
identificationVariableDefContext = null;
|
identificationVariableDefContext = null;
|
||||||
}
|
}
|
||||||
final String alias = visitIdentificationVariableDef( identificationVariableDefContext );
|
final String alias = visitVariable( identificationVariableDefContext );
|
||||||
final boolean fetch = parserJoin.getChild( 2 ) instanceof TerminalNode;
|
final boolean fetch = parserJoin.getChild( 2 ) instanceof TerminalNode;
|
||||||
|
|
||||||
if ( fetch && processingStateStack.depth() > 1 ) {
|
if ( fetch && processingStateStack.depth() > 1 ) {
|
||||||
|
@ -1645,9 +1645,9 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
final SqmQualifiedJoin<X, ?> join = (SqmQualifiedJoin<X, ?>) qualifiedJoinRhsContext.getChild( 0 ).accept( this );
|
final SqmQualifiedJoin<X, ?> join = (SqmQualifiedJoin<X, ?>) qualifiedJoinPathContext.getChild( 0 ).accept( this );
|
||||||
|
|
||||||
final HqlParser.QualifiedJoinPredicateContext qualifiedJoinPredicateContext = parserJoin.qualifiedJoinPredicate();
|
final HqlParser.JoinRestrictionContext qualifiedJoinRestrictionContext = parserJoin.joinRestriction();
|
||||||
if ( join instanceof SqmEntityJoin<?> ) {
|
if ( join instanceof SqmEntityJoin<?> ) {
|
||||||
sqmRoot.addSqmJoin( join );
|
sqmRoot.addSqmJoin( join );
|
||||||
}
|
}
|
||||||
|
@ -1663,15 +1663,15 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( qualifiedJoinPredicateContext != null && attributeJoin.isFetched() ) {
|
if ( qualifiedJoinRestrictionContext != null && attributeJoin.isFetched() ) {
|
||||||
throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
|
throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( qualifiedJoinPredicateContext != null ) {
|
if ( qualifiedJoinRestrictionContext != null ) {
|
||||||
dotIdentifierConsumerStack.push( new QualifiedJoinPredicatePathConsumer( join, this ) );
|
dotIdentifierConsumerStack.push( new QualifiedJoinPredicatePathConsumer( join, this ) );
|
||||||
try {
|
try {
|
||||||
join.setJoinPredicate( (SqmPredicate) qualifiedJoinPredicateContext.getChild( 1 ).accept( this ) );
|
join.setJoinPredicate( (SqmPredicate) qualifiedJoinRestrictionContext.getChild( 1 ).accept( this ) );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
dotIdentifierConsumerStack.pop();
|
dotIdentifierConsumerStack.pop();
|
||||||
|
@ -1692,14 +1692,14 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
protected void consumeJpaCollectionJoin(
|
protected void consumeJpaCollectionJoin(
|
||||||
HqlParser.JpaCollectionJoinContext ctx,
|
HqlParser.JpaCollectionJoinContext ctx,
|
||||||
SqmRoot<?> sqmRoot) {
|
SqmRoot<?> sqmRoot) {
|
||||||
final HqlParser.IdentificationVariableDefContext identificationVariableDefContext;
|
final HqlParser.VariableContext identificationVariableDefContext;
|
||||||
if ( ctx.getChildCount() > 5 ) {
|
if ( ctx.getChildCount() > 5 ) {
|
||||||
identificationVariableDefContext = (HqlParser.IdentificationVariableDefContext) ctx.getChild( 5 );
|
identificationVariableDefContext = (HqlParser.VariableContext) ctx.getChild( 5 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
identificationVariableDefContext = null;
|
identificationVariableDefContext = null;
|
||||||
}
|
}
|
||||||
final String alias = visitIdentificationVariableDef( identificationVariableDefContext );
|
final String alias = visitVariable( identificationVariableDefContext );
|
||||||
dotIdentifierConsumerStack.push(
|
dotIdentifierConsumerStack.push(
|
||||||
new QualifiedJoinPathConsumer(
|
new QualifiedJoinPathConsumer(
|
||||||
sqmRoot,
|
sqmRoot,
|
||||||
|
@ -1922,7 +1922,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
if ( ctx instanceof HqlParser.GeneralPathFragmentContext && ctx.getChildCount() == 1 ) {
|
if ( ctx instanceof HqlParser.GeneralPathFragmentContext && ctx.getChildCount() == 1 ) {
|
||||||
ctx = ctx.getChild( 0 );
|
ctx = ctx.getChild( 0 );
|
||||||
|
|
||||||
if ( ctx instanceof HqlParser.DotIdentifierSequenceContext ) {
|
if ( ctx instanceof HqlParser.SimplePathContext ) {
|
||||||
return creationContext.getJpaMetamodel().getAllowedEnumLiteralTexts().get( ctx.getText() );
|
return creationContext.getJpaMetamodel().getAllowedEnumLiteralTexts().get( ctx.getText() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2059,7 +2059,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
return new SqmInSubQueryPredicate<>(
|
return new SqmInSubQueryPredicate<>(
|
||||||
testExpression,
|
testExpression,
|
||||||
createCollectionReferenceSubQuery(
|
createCollectionReferenceSubQuery(
|
||||||
(HqlParser.DotIdentifierSequenceContext) collectionReferenceInListContext.getChild( 2 ),
|
(HqlParser.SimplePathContext) collectionReferenceInListContext.getChild( 2 ),
|
||||||
(TerminalNode) collectionReferenceInListContext.getChild( 0 )
|
(TerminalNode) collectionReferenceInListContext.getChild( 0 )
|
||||||
),
|
),
|
||||||
negated,
|
negated,
|
||||||
|
@ -2074,7 +2074,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
@Override
|
@Override
|
||||||
public SqmPredicate visitExistsCollectionPartPredicate(HqlParser.ExistsCollectionPartPredicateContext ctx) {
|
public SqmPredicate visitExistsCollectionPartPredicate(HqlParser.ExistsCollectionPartPredicateContext ctx) {
|
||||||
final SqmSubQuery<Object> subQuery = createCollectionReferenceSubQuery(
|
final SqmSubQuery<Object> subQuery = createCollectionReferenceSubQuery(
|
||||||
(HqlParser.DotIdentifierSequenceContext) ctx.getChild( 3 ),
|
(HqlParser.SimplePathContext) ctx.getChild( 3 ),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
return new SqmExistsPredicate( subQuery, creationContext.getNodeBuilder() );
|
return new SqmExistsPredicate( subQuery, creationContext.getNodeBuilder() );
|
||||||
|
@ -2326,7 +2326,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitCollationExpression(HqlParser.CollationExpressionContext ctx) {
|
public Object visitCollateFunction(HqlParser.CollateFunctionContext ctx) {
|
||||||
if ( creationOptions.useStrictJpaCompliance() ) {
|
if ( creationOptions.useStrictJpaCompliance() ) {
|
||||||
throw new StrictJpaComplianceViolation(
|
throw new StrictJpaComplianceViolation(
|
||||||
StrictJpaComplianceViolation.Type.COLLATIONS
|
StrictJpaComplianceViolation.Type.COLLATIONS
|
||||||
|
@ -3125,7 +3125,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmExpression<?> visitJpaNonStandardFunction(HqlParser.JpaNonStandardFunctionContext ctx) {
|
public SqmExpression<?> visitJpaNonstandardFunction(HqlParser.JpaNonstandardFunctionContext ctx) {
|
||||||
final String functionName = QuotingHelper.unquoteStringLiteral( ctx.getChild( 2 ).getText() ).toLowerCase();
|
final String functionName = QuotingHelper.unquoteStringLiteral( ctx.getChild( 2 ).getText() ).toLowerCase();
|
||||||
final List<SqmTypedNode<?>> functionArguments;
|
final List<SqmTypedNode<?>> functionArguments;
|
||||||
if ( ctx.getChildCount() > 4 ) {
|
if ( ctx.getChildCount() > 4 ) {
|
||||||
|
@ -3171,7 +3171,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
final ParseTree argumentChild = ctx.getChild( 2 );
|
final ParseTree argumentChild = ctx.getChild( 2 );
|
||||||
final List<SqmTypedNode<?>> functionArguments;
|
final List<SqmTypedNode<?>> functionArguments;
|
||||||
if ( argumentChild instanceof HqlParser.NonStandardFunctionArgumentsContext ) {
|
if ( argumentChild instanceof HqlParser.GenericFunctionArgumentsContext ) {
|
||||||
functionArguments = (List<SqmTypedNode<?>>) argumentChild.accept( this );
|
functionArguments = (List<SqmTypedNode<?>>) argumentChild.accept( this );
|
||||||
}
|
}
|
||||||
else if ( "*".equals( argumentChild.getText() ) ) {
|
else if ( "*".equals( argumentChild.getText() ) ) {
|
||||||
|
@ -3221,7 +3221,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SqmTypedNode<?>> visitNonStandardFunctionArguments(HqlParser.NonStandardFunctionArgumentsContext ctx) {
|
public List<SqmTypedNode<?>> visitGenericFunctionArguments(HqlParser.GenericFunctionArgumentsContext ctx) {
|
||||||
final int size = ctx.getChildCount();
|
final int size = ctx.getChildCount();
|
||||||
final int lastIndex = size - 1;
|
final int lastIndex = size - 1;
|
||||||
// Shift 1 bit instead of division by 2
|
// Shift 1 bit instead of division by 2
|
||||||
|
@ -3591,7 +3591,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
return new SqmEvery<>(
|
return new SqmEvery<>(
|
||||||
createCollectionReferenceSubQuery(
|
createCollectionReferenceSubQuery(
|
||||||
(HqlParser.DotIdentifierSequenceContext) ctx.getChild( 3 ),
|
(HqlParser.SimplePathContext) ctx.getChild( 3 ),
|
||||||
(TerminalNode) ctx.getChild( 1 )
|
(TerminalNode) ctx.getChild( 1 )
|
||||||
),
|
),
|
||||||
creationContext.getNodeBuilder()
|
creationContext.getNodeBuilder()
|
||||||
|
@ -3627,7 +3627,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
return new SqmAny<>(
|
return new SqmAny<>(
|
||||||
createCollectionReferenceSubQuery(
|
createCollectionReferenceSubQuery(
|
||||||
(HqlParser.DotIdentifierSequenceContext) ctx.getChild( 3 ),
|
(HqlParser.SimplePathContext) ctx.getChild( 3 ),
|
||||||
(TerminalNode) ctx.getChild( 1 )
|
(TerminalNode) ctx.getChild( 1 )
|
||||||
),
|
),
|
||||||
creationContext.getNodeBuilder()
|
creationContext.getNodeBuilder()
|
||||||
|
@ -3636,7 +3636,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private <X> SqmSubQuery<X> createCollectionReferenceSubQuery(
|
private <X> SqmSubQuery<X> createCollectionReferenceSubQuery(
|
||||||
HqlParser.DotIdentifierSequenceContext pathCtx,
|
HqlParser.SimplePathContext pathCtx,
|
||||||
TerminalNode collectionReferenceCtx) {
|
TerminalNode collectionReferenceCtx) {
|
||||||
final SqmPath<?> pluralAttributePath = consumeDomainPath( pathCtx );
|
final SqmPath<?> pluralAttributePath = consumeDomainPath( pathCtx );
|
||||||
final SqmPathSource<?> referencedPathSource = pluralAttributePath.getReferencedPathSource();
|
final SqmPathSource<?> referencedPathSource = pluralAttributePath.getReferencedPathSource();
|
||||||
|
@ -4008,7 +4008,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
@Override
|
@Override
|
||||||
public SemanticPathPart visitGeneralPathFragment(HqlParser.GeneralPathFragmentContext ctx) {
|
public SemanticPathPart visitGeneralPathFragment(HqlParser.GeneralPathFragmentContext ctx) {
|
||||||
return visitIndexedPathAccessFragment(
|
return visitIndexedPathAccessFragment(
|
||||||
(HqlParser.DotIdentifierSequenceContext) ctx.getChild( 0 ),
|
(HqlParser.SimplePathContext) ctx.getChild( 0 ),
|
||||||
ctx.getChildCount() == 1 ? null : (HqlParser.IndexedPathAccessFragmentContext) ctx.getChild( 1 )
|
ctx.getChildCount() == 1 ? null : (HqlParser.IndexedPathAccessFragmentContext) ctx.getChild( 1 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4028,9 +4028,9 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
else if ( firstChild instanceof HqlParser.MapKeyNavigablePathContext ) {
|
else if ( firstChild instanceof HqlParser.MapKeyNavigablePathContext ) {
|
||||||
return visitMapKeyNavigablePath( (HqlParser.MapKeyNavigablePathContext) firstChild );
|
return visitMapKeyNavigablePath( (HqlParser.MapKeyNavigablePathContext) firstChild );
|
||||||
}
|
}
|
||||||
else if ( firstChild instanceof HqlParser.DotIdentifierSequenceContext && ctx.getChildCount() == 2 ) {
|
else if ( firstChild instanceof HqlParser.SimplePathContext && ctx.getChildCount() == 2 ) {
|
||||||
return visitIndexedPathAccessFragment(
|
return visitIndexedPathAccessFragment(
|
||||||
(HqlParser.DotIdentifierSequenceContext) firstChild,
|
(HqlParser.SimplePathContext) firstChild,
|
||||||
(HqlParser.IndexedPathAccessFragmentContext) ctx.getChild( 1 )
|
(HqlParser.IndexedPathAccessFragmentContext) ctx.getChild( 1 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4039,9 +4039,9 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private SemanticPathPart visitIndexedPathAccessFragment(
|
private SemanticPathPart visitIndexedPathAccessFragment(
|
||||||
HqlParser.DotIdentifierSequenceContext ctx,
|
HqlParser.SimplePathContext ctx,
|
||||||
HqlParser.IndexedPathAccessFragmentContext idxCtx) {
|
HqlParser.IndexedPathAccessFragmentContext idxCtx) {
|
||||||
final SemanticPathPart pathPart = visitDotIdentifierSequence( ctx );
|
final SemanticPathPart pathPart = visitSimplePath( ctx );
|
||||||
|
|
||||||
if ( idxCtx == null ) {
|
if ( idxCtx == null ) {
|
||||||
return pathPart;
|
return pathPart;
|
||||||
|
@ -4075,7 +4075,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SemanticPathPart visitDotIdentifierSequence(HqlParser.DotIdentifierSequenceContext ctx) {
|
public SemanticPathPart visitSimplePath(HqlParser.SimplePathContext ctx) {
|
||||||
final int numberOfContinuations = ctx.getChildCount() - 1;
|
final int numberOfContinuations = ctx.getChildCount() - 1;
|
||||||
final boolean hasContinuations = numberOfContinuations != 0;
|
final boolean hasContinuations = numberOfContinuations != 0;
|
||||||
|
|
||||||
|
@ -4091,7 +4091,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
if ( hasContinuations ) {
|
if ( hasContinuations ) {
|
||||||
for ( int i = 1; i < ctx.getChildCount(); i++ ) {
|
for ( int i = 1; i < ctx.getChildCount(); i++ ) {
|
||||||
final HqlParser.DotIdentifierSequenceContinuationContext continuation = (HqlParser.DotIdentifierSequenceContinuationContext) ctx.getChild( i );
|
final HqlParser.SimplePathElementContext continuation = (HqlParser.SimplePathElementContext) ctx.getChild( i );
|
||||||
final HqlParser.IdentifierContext identifier = (HqlParser.IdentifierContext) continuation.getChild( 1 );
|
final HqlParser.IdentifierContext identifier = (HqlParser.IdentifierContext) continuation.getChild( 1 );
|
||||||
assert identifier.getChildCount() == 1;
|
assert identifier.getChildCount() == 1;
|
||||||
dotIdentifierConsumer.consumeIdentifier(
|
dotIdentifierConsumer.consumeIdentifier(
|
||||||
|
@ -4108,7 +4108,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
@Override
|
@Override
|
||||||
public SqmPath<?> visitTreatedNavigablePath(HqlParser.TreatedNavigablePathContext ctx) {
|
public SqmPath<?> visitTreatedNavigablePath(HqlParser.TreatedNavigablePathContext ctx) {
|
||||||
final DotIdentifierConsumer consumer = dotIdentifierConsumerStack.getCurrent();
|
final DotIdentifierConsumer consumer = dotIdentifierConsumerStack.getCurrent();
|
||||||
if ( consumer instanceof QualifiedJoinPathConsumer ) {
|
if ( consumer instanceof QualifiedJoinPathConsumer) {
|
||||||
( (QualifiedJoinPathConsumer) consumer ).setNested( true );
|
( (QualifiedJoinPathConsumer) consumer ).setNested( true );
|
||||||
}
|
}
|
||||||
consumeManagedTypeReference( (HqlParser.PathContext) ctx.getChild( 2 ) );
|
consumeManagedTypeReference( (HqlParser.PathContext) ctx.getChild( 2 ) );
|
||||||
|
@ -4129,7 +4129,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
result = consumeDomainPath( (HqlParser.DotIdentifierSequenceContext) ctx.getChild( 6 ).getChild( 1 ) );
|
result = consumeDomainPath( (HqlParser.SimplePathContext) ctx.getChild( 6 ).getChild( 1 ) );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
dotIdentifierConsumerStack.pop();
|
dotIdentifierConsumerStack.pop();
|
||||||
|
@ -4165,7 +4165,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
SqmPath<?> result = pluralAttributePath.resolvePathPart( CollectionPart.Nature.ELEMENT.getName(), true, this );
|
SqmPath<?> result = pluralAttributePath.resolvePathPart( CollectionPart.Nature.ELEMENT.getName(), true, this );
|
||||||
|
|
||||||
if ( ctx.getChildCount() == 5 ) {
|
if ( ctx.getChildCount() == 5 ) {
|
||||||
result = consumeDomainPath( (HqlParser.DotIdentifierSequenceContext) ctx.getChild( 4 ).getChild( 1 ) );
|
result = consumeDomainPath( (HqlParser.SimplePathContext) ctx.getChild( 4 ).getChild( 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -4194,7 +4194,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
public SqmPath visitMapKeyNavigablePath(HqlParser.MapKeyNavigablePathContext ctx) {
|
public SqmPath visitMapKeyNavigablePath(HqlParser.MapKeyNavigablePathContext ctx) {
|
||||||
final DotIdentifierConsumer consumer = dotIdentifierConsumerStack.getCurrent();
|
final DotIdentifierConsumer consumer = dotIdentifierConsumerStack.getCurrent();
|
||||||
final boolean madeNested;
|
final boolean madeNested;
|
||||||
if ( consumer instanceof QualifiedJoinPathConsumer ) {
|
if ( consumer instanceof QualifiedJoinPathConsumer) {
|
||||||
final QualifiedJoinPathConsumer qualifiedJoinPathConsumer = (QualifiedJoinPathConsumer) consumer;
|
final QualifiedJoinPathConsumer qualifiedJoinPathConsumer = (QualifiedJoinPathConsumer) consumer;
|
||||||
madeNested = !qualifiedJoinPathConsumer.isNested();
|
madeNested = !qualifiedJoinPathConsumer.isNested();
|
||||||
if ( madeNested ) {
|
if ( madeNested ) {
|
||||||
|
@ -4210,7 +4210,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
SqmPath<?> result;
|
SqmPath<?> result;
|
||||||
if ( sqmPath instanceof SqmMapJoin ) {
|
if ( sqmPath instanceof SqmMapJoin ) {
|
||||||
final SqmMapJoin<?, ?, ?> sqmMapJoin = (SqmMapJoin<?, ?, ?>) sqmPath;
|
final SqmMapJoin<?, ?, ?> sqmMapJoin = (SqmMapJoin<?, ?, ?>) sqmPath;
|
||||||
if ( consumer instanceof QualifiedJoinPathConsumer ) {
|
if ( consumer instanceof QualifiedJoinPathConsumer) {
|
||||||
if ( madeNested && !hasContinuation ) {
|
if ( madeNested && !hasContinuation ) {
|
||||||
// Reset the nested state before consuming the terminal identifier
|
// Reset the nested state before consuming the terminal identifier
|
||||||
( (QualifiedJoinPathConsumer) consumer ).setNested( false );
|
( (QualifiedJoinPathConsumer) consumer ).setNested( false );
|
||||||
|
@ -4233,9 +4233,9 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
// Reset the nested state before consuming the terminal identifier
|
// Reset the nested state before consuming the terminal identifier
|
||||||
( (QualifiedJoinPathConsumer) consumer ).setNested( false );
|
( (QualifiedJoinPathConsumer) consumer ).setNested( false );
|
||||||
}
|
}
|
||||||
final HqlParser.DotIdentifierSequenceContext identCtx = (HqlParser.DotIdentifierSequenceContext) ctx.getChild( 4 )
|
final HqlParser.SimplePathContext identCtx = (HqlParser.SimplePathContext) ctx.getChild( 4 )
|
||||||
.getChild( 1 );
|
.getChild( 1 );
|
||||||
if ( consumer instanceof QualifiedJoinPathConsumer ) {
|
if ( consumer instanceof QualifiedJoinPathConsumer) {
|
||||||
result = consumeDomainPath( identCtx );
|
result = consumeDomainPath( identCtx );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -4269,7 +4269,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SqmPath<?> consumeDomainPath(HqlParser.DotIdentifierSequenceContext sequence) {
|
private SqmPath<?> consumeDomainPath(HqlParser.SimplePathContext sequence) {
|
||||||
final SemanticPathPart consumedPart = (SemanticPathPart) sequence.accept( this );
|
final SemanticPathPart consumedPart = (SemanticPathPart) sequence.accept( this );
|
||||||
if ( consumedPart instanceof SqmPath ) {
|
if ( consumedPart instanceof SqmPath ) {
|
||||||
return (SqmPath<?>) consumedPart;
|
return (SqmPath<?>) consumedPart;
|
||||||
|
|
Loading…
Reference in New Issue