|
7 | 7 | package org.hibernate.test.hql;
|
8 | 8 |
|
9 | 9 | import java.util.ArrayList;
|
| 10 | +import java.util.Arrays; |
10 | 11 | import java.util.HashMap;
|
11 | 12 | import java.util.List;
|
12 | 13 | import java.util.Map;
|
@@ -156,4 +157,102 @@ public void testObjectAsParameter() {
|
156 | 157 | s.getTransaction().commit();
|
157 | 158 | s.close();
|
158 | 159 | }
|
| 160 | + |
| 161 | + @Test |
| 162 | + @TestForIssue(jiraKey = "HHH-13310") |
| 163 | + public void testGetParameterListValue() { |
| 164 | + inTransaction( |
| 165 | + session -> { |
| 166 | + Query query = session.createQuery( "from Animal a where a.id in :ids" ); |
| 167 | + query.setParameterList( "ids", Arrays.asList( 1L, 2L ) ); |
| 168 | + |
| 169 | + Object parameterListValue = query.getParameterValue( "ids" ); |
| 170 | + assertThat( parameterListValue, is( Arrays.asList( 1L, 2L ) ) ); |
| 171 | + } |
| 172 | + ); |
| 173 | + } |
| 174 | + |
| 175 | + @Test |
| 176 | + @TestForIssue(jiraKey = "HHH-13310") |
| 177 | + public void testGetParameterListValueAfterParameterExpansion() { |
| 178 | + inTransaction( |
| 179 | + session -> { |
| 180 | + Query query = session.createQuery( "from Animal a where a.id in :ids" ); |
| 181 | + query.setParameterList( "ids", Arrays.asList( 1L, 2L ) ); |
| 182 | + query.list(); |
| 183 | + |
| 184 | + Object parameterListValue = query.getParameterValue( "ids" ); |
| 185 | + assertThat( parameterListValue, is( Arrays.asList( 1L, 2L ) ) ); |
| 186 | + } |
| 187 | + ); |
| 188 | + } |
| 189 | + |
| 190 | + @Test(expected = IllegalStateException.class) |
| 191 | + @TestForIssue(jiraKey = "HHH-13310") |
| 192 | + public void testGetNotBoundParameterListValue() { |
| 193 | + inTransaction( |
| 194 | + session -> { |
| 195 | + Query query = session.createQuery( "from Animal a where a.id in :ids" ); |
| 196 | + query.getParameterValue( "ids" ); |
| 197 | + } |
| 198 | + ); |
| 199 | + } |
| 200 | + |
| 201 | + @Test |
| 202 | + @TestForIssue(jiraKey = "HHH-13310") |
| 203 | + public void testGetPositionalParameterListValue() { |
| 204 | + inTransaction( |
| 205 | + session -> { |
| 206 | + Query query = session.createQuery( "from Animal a where a.id in ?1" ); |
| 207 | + query.setParameter( 1, Arrays.asList( 1L, 2L ) ); |
| 208 | + |
| 209 | + Object parameterListValue = query.getParameterValue( 1 ); |
| 210 | + assertThat( parameterListValue, is( Arrays.asList( 1L, 2L ) ) ); |
| 211 | + |
| 212 | + query.list(); |
| 213 | + } |
| 214 | + ); |
| 215 | + } |
| 216 | + |
| 217 | + @Test |
| 218 | + @TestForIssue(jiraKey = "HHH-13310") |
| 219 | + public void testGetPositionalParameterValue() { |
| 220 | + inTransaction( |
| 221 | + session -> { |
| 222 | + Query query = session.createQuery( "from Animal a where a.id = ?1" ); |
| 223 | + query.setParameter( 1, 1L ); |
| 224 | + |
| 225 | + Object parameterListValue = query.getParameterValue( 1 ); |
| 226 | + assertThat( parameterListValue, is( 1L ) ); |
| 227 | + |
| 228 | + query.list(); |
| 229 | + } |
| 230 | + ); |
| 231 | + } |
| 232 | + |
| 233 | + @Test |
| 234 | + @TestForIssue(jiraKey = "HHH-13310") |
| 235 | + public void testGetParameterByPositionListValueAfterParameterExpansion() { |
| 236 | + inTransaction( |
| 237 | + session -> { |
| 238 | + Query query = session.createQuery( "from Animal a where a.id in ?1" ); |
| 239 | + query.setParameterList( 1, Arrays.asList( 1L, 2L ) ); |
| 240 | + query.list(); |
| 241 | + |
| 242 | + Object parameterListValue = query.getParameterValue( 1 ); |
| 243 | + assertThat( parameterListValue, is( Arrays.asList( 1L, 2L ) ) ); |
| 244 | + } |
| 245 | + ); |
| 246 | + } |
| 247 | + |
| 248 | + @Test(expected = IllegalStateException.class) |
| 249 | + @TestForIssue(jiraKey = "HHH-13310") |
| 250 | + public void testGetPositionalNotBoundParameterListValue() { |
| 251 | + inTransaction( |
| 252 | + session -> { |
| 253 | + Query query = session.createQuery( "from Animal a where a.id in ?1" ); |
| 254 | + query.getParameterValue( 1 ); |
| 255 | + } |
| 256 | + ); |
| 257 | + } |
159 | 258 | }
|
0 commit comments