|
38 | 38 | @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true"), |
39 | 39 | @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"), |
40 | 40 | @Setting(name = AvailableSettings.DIALECT_NATIVE_PARAM_MARKERS, value = "false"), |
| 41 | + @Setting(name = AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, value = "bind") |
41 | 42 | }, |
42 | 43 | useCollectingStatementInspector = true |
43 | 44 | ) |
@@ -103,6 +104,30 @@ public void testInClauseParameterPaddingForExpressions(EntityManagerFactoryScope |
103 | 104 | assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (d1_0.id,d1_0.id,d1_0.id)" ) ); |
104 | 105 | } |
105 | 106 |
|
| 107 | + |
| 108 | + @Test @JiraKey("HHH-14119") |
| 109 | + public void testInClauseParameterBindingPadding(EntityManagerFactoryScope scope) { |
| 110 | + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); |
| 111 | + statementInspector.clear(); |
| 112 | + |
| 113 | + scope.inTransaction( entityManager -> { |
| 114 | + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); |
| 115 | + CriteriaQuery<Integer> query = cb.createQuery( Integer.class ); |
| 116 | + Root<Document> document = query.from( Document.class ); |
| 117 | + |
| 118 | + query |
| 119 | + .select( document.get( "id" ) ) |
| 120 | + .where( document.get( "id" ).in( Arrays.asList( 1, 2, 3, 4, 5 ) ) ); |
| 121 | + |
| 122 | + |
| 123 | + List<Integer> ids = entityManager.createQuery( query ).getResultList(); |
| 124 | + assertEquals( 1, ids.size() ); |
| 125 | + } ); |
| 126 | + |
| 127 | + assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (?,?,?,?,?,?,?,?)" ) ); |
| 128 | + |
| 129 | + } |
| 130 | + |
106 | 131 | @Entity(name = "Document") |
107 | 132 | public static class Document { |
108 | 133 |
|
|
0 commit comments