diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java index 34332e641e9e..25803ba3f949 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java @@ -176,6 +176,22 @@ void testSimpleMutationRestrictionAsReference(SessionFactoryScope factoryScope) assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( " where be1_0.position between ? and ?" ); } + @Test + void testSimpleMutationRestrictionStatelessAsReference(SessionFactoryScope factoryScope) { + final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector(); + var deleteBasicEntity = MutationSpecification + .create( BasicEntity.class, "delete BasicEntity" ) + .restrict( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) + .reference(); + factoryScope.inStatelessTransaction( statelessSession -> { + sqlCollector.clear(); + statelessSession.createQuery( deleteBasicEntity ).executeUpdate(); + } ); + + assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 ); + assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( " where be1_0.position between ? and ?" ); + } + @Test void testRootEntityForm(SessionFactoryScope factoryScope) { final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();