From b3254a2fa6a23dd20d08cd05bbcdd43f03e9b934 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 19 Mar 2020 13:01:35 -0500 Subject: [PATCH] SQM 'insert select', 'insert values', and 'update' queries --- .../antlr/org/hibernate/grammars/hql/HqlParser.g4 | 8 ++++---- .../query/hql/internal/SemanticQueryBuilder.java | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 b/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 index 2621f524ff..51907427a5 100644 --- a/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 +++ b/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 @@ -35,16 +35,16 @@ subQuery : querySpec ; -rootEntity +dmlTarget : entityName identificationVariableDef? ; deleteStatement - : DELETE FROM? rootEntity whereClause? + : DELETE FROM? dmlTarget whereClause? ; updateStatement - : UPDATE rootEntity setClause whereClause? + : UPDATE dmlTarget setClause whereClause? ; setClause @@ -56,7 +56,7 @@ assignment ; insertStatement - : INSERT INTO? rootEntity targetFieldsSpec (querySpec | valuesList) + : INSERT INTO? dmlTarget targetFieldsSpec (querySpec | valuesList) ; targetFieldsSpec diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java index f96451f401..d8a95bbe57 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java @@ -309,8 +309,8 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre public SqmInsertStatement visitInsertStatement(HqlParser.InsertStatementContext ctx) { final SqmRoot root = new SqmRoot<>( - visitEntityName( ctx.rootEntity().entityName() ), - visitIdentificationVariableDef( ctx.rootEntity().identificationVariableDef() ), + visitEntityName( ctx.dmlTarget().entityName() ), + visitIdentificationVariableDef( ctx.dmlTarget().identificationVariableDef() ), creationContext.getNodeBuilder() ); @@ -379,8 +379,8 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre @Override public SqmUpdateStatement visitUpdateStatement(HqlParser.UpdateStatementContext ctx) { final SqmRoot root = new SqmRoot<>( - visitEntityName( ctx.rootEntity().entityName() ), - visitIdentificationVariableDef( ctx.rootEntity().identificationVariableDef() ), + visitEntityName( ctx.dmlTarget().entityName() ), + visitIdentificationVariableDef( ctx.dmlTarget().identificationVariableDef() ), creationContext.getNodeBuilder() ); @@ -413,8 +413,8 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre @Override public SqmDeleteStatement visitDeleteStatement(HqlParser.DeleteStatementContext ctx) { final SqmRoot root = new SqmRoot<>( - visitEntityName( ctx.rootEntity().entityName() ), - visitIdentificationVariableDef( ctx.rootEntity().identificationVariableDef() ), + visitEntityName( ctx.dmlTarget().entityName() ), + visitIdentificationVariableDef( ctx.dmlTarget().identificationVariableDef() ), creationContext.getNodeBuilder() );