Skip to content

Commit 3331682

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,27 @@ 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+
var criteriaBuilder = session.getCriteriaBuilder();
202+
var query = criteriaBuilder.createQuery( BasicEntity.class );
203+
var entity = query.from( BasicEntity.class );
204+
query.select( entity );
205+
SelectionSpecification.create( query )
206+
.mutate( (b, q, r) -> q.where( b.like( r.get( BasicEntity_.name ), "%" ) ) )
207+
.addOrdering( Order.asc( BasicEntity_.position ) )
208+
.createQuery( session )
209+
.getResultList();
210+
} );
211+
212+
assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
213+
assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( " order by be1_0.position" );
214+
}
215+
195216
@Test
196217
void testBaseParameters(SessionFactoryScope factoryScope) {
197218
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();

0 commit comments

Comments
 (0)