diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java index df3b0da243..2f5fcf03f0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java @@ -33,6 +33,7 @@ public class StandardSqlAstDeleteTranslator appendSql( sqlAst.getTargetTable().getTableExpression() ); if ( sqlAst.getRestriction() != null ) { + appendSql( " where " ); sqlAst.getRestriction().accept( this ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/HqlDeleteExecutionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/HqlDeleteExecutionTests.java index f8bc22fa70..4408b31294 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/HqlDeleteExecutionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/HqlDeleteExecutionTests.java @@ -29,4 +29,13 @@ public class HqlDeleteExecutionTests { session -> session.createQuery( "delete BasicEntity" ).executeUpdate() ); } + + @Test + public void testSimpleRestrictedDelete(SessionFactoryScope scope) { + scope.inTransaction( + session -> session.createQuery( "delete BasicEntity where data = :filter" ) + .setParameter( "filter", "abc" ) + .executeUpdate() + ); + } }