Skip to content

Commit 90a6564

Browse files
committed
HHH-19364 test for mutate()
1 parent 230cbe9 commit 90a6564

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ void testCriteriaForm(SessionFactoryScope factoryScope) {
192192
assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( " order by be1_0.position" );
193193
}
194194

195+
@Test
196+
void testCriteriaFormWithMutation(SessionFactoryScope factoryScope) {
197+
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
198+
199+
factoryScope.inTransaction( (session) -> {
200+
sqlCollector.clear();
201+
SelectionSpecification.create( BasicEntity.class )
202+
.mutate( (builder, query, entity) -> query.where( builder.like( entity.get( BasicEntity_.name ), "%" ) ) )
203+
.addOrdering( Order.asc( BasicEntity_.position ) )
204+
.createQuery( session )
205+
.getResultList();
206+
} );
207+
208+
assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
209+
assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( " order by be1_0.position" );
210+
}
211+
195212
@Test
196213
void testBaseParameters(SessionFactoryScope factoryScope) {
197214
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();

0 commit comments

Comments
 (0)