HHH-14119 test showing parameter padding works with criteria literals
This commit is contained in:
parent
11139c288a
commit
cacd1a7ecc
|
@ -38,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
@Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true"),
|
||||
@Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"),
|
||||
@Setting(name = AvailableSettings.DIALECT_NATIVE_PARAM_MARKERS, value = "false"),
|
||||
@Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "bind")
|
||||
},
|
||||
useCollectingStatementInspector = true
|
||||
)
|
||||
|
@ -103,6 +104,30 @@ public class InClauseParameterPaddingCriteriaTest {
|
|||
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (d1_0.id,d1_0.id,d1_0.id)" ) );
|
||||
}
|
||||
|
||||
|
||||
@Test @JiraKey("HHH-14119")
|
||||
public void testInClauseParameterBindingPadding(EntityManagerFactoryScope scope) {
|
||||
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
|
||||
statementInspector.clear();
|
||||
|
||||
scope.inTransaction( entityManager -> {
|
||||
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<Integer> query = cb.createQuery( Integer.class );
|
||||
Root<Document> document = query.from( Document.class );
|
||||
|
||||
query
|
||||
.select( document.get( "id" ) )
|
||||
.where( document.get( "id" ).in( Arrays.asList( 1, 2, 3, 4, 5 ) ) );
|
||||
|
||||
|
||||
List<Integer> ids = entityManager.createQuery( query ).getResultList();
|
||||
assertEquals( 1, ids.size() );
|
||||
} );
|
||||
|
||||
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (?,?,?,?,?,?,?,?)" ) );
|
||||
|
||||
}
|
||||
|
||||
@Entity(name = "Document")
|
||||
public static class Document {
|
||||
|
||||
|
|
Loading…
Reference in New Issue