18
18
import org .hibernate .dialect .HSQLDialect ;
19
19
import org .hibernate .dialect .SybaseASE15Dialect ;
20
20
import org .hibernate .hql .internal .ast .QuerySyntaxException ;
21
+
22
+ import org .hibernate .testing .DialectChecks ;
23
+ import org .hibernate .testing .RequiresDialectFeature ;
21
24
import org .hibernate .testing .SkipForDialect ;
22
25
import org .hibernate .testing .SkipForDialects ;
23
26
import org .hibernate .testing .TestForIssue ;
@@ -221,16 +224,17 @@ public void testNotEqualOperator() {
221
224
*/
222
225
@ Test ( expected = QuerySyntaxException .class )
223
226
@ TestForIssue ( jiraKey = "HHH-5946" )
227
+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
224
228
public void testLessThanOperator () {
225
229
final Session s = openSession ();
226
- s . getTransaction (). begin ();
227
-
228
- final Query q = s . createQuery ( "from Transaction where value < :amount" );
229
- q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "EUR" ) ) );
230
- q . list ();
231
-
232
- s . getTransaction (). commit ();
233
- s . close ();
230
+ try {
231
+ final Query q = s . createQuery ( "from Transaction where value < :amount" );
232
+ q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "EUR" ) ) );
233
+ q . list ( );
234
+ }
235
+ finally {
236
+ s . close ();
237
+ }
234
238
}
235
239
236
240
/**
@@ -239,16 +243,17 @@ public void testLessThanOperator() {
239
243
*/
240
244
@ Test ( expected = QuerySyntaxException .class )
241
245
@ TestForIssue ( jiraKey = "HHH-5946" )
246
+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
242
247
public void testLessOrEqualOperator () {
243
248
final Session s = openSession ();
244
- s . getTransaction (). begin ();
245
-
246
- final Query q = s . createQuery ( "from Transaction where value <= :amount" );
247
- q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "USD" ) ) );
248
- q . list ();
249
-
250
- s . getTransaction (). commit ();
251
- s . close ();
249
+ try {
250
+ final Query q = s . createQuery ( "from Transaction where value <= :amount" );
251
+ q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "USD" ) ) );
252
+ q . list ( );
253
+ }
254
+ finally {
255
+ s . close ();
256
+ }
252
257
}
253
258
254
259
/**
@@ -257,16 +262,17 @@ public void testLessOrEqualOperator() {
257
262
*/
258
263
@ Test ( expected = QuerySyntaxException .class )
259
264
@ TestForIssue ( jiraKey = "HHH-5946" )
265
+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
260
266
public void testGreaterThanOperator () {
261
267
final Session s = openSession ();
262
- s . getTransaction (). begin ();
263
-
264
- final Query q = s . createQuery ( "from Transaction where value > :amount" );
265
- q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "EUR" ) ) );
266
- q . list ();
267
-
268
- s . getTransaction (). commit ();
269
- s . close ();
268
+ try {
269
+ final Query q = s . createQuery ( "from Transaction where value > :amount" );
270
+ q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "EUR" ) ) );
271
+ q . list ( );
272
+ }
273
+ finally {
274
+ s . close ();
275
+ }
270
276
}
271
277
272
278
/**
@@ -275,16 +281,17 @@ public void testGreaterThanOperator() {
275
281
*/
276
282
@ Test ( expected = QuerySyntaxException .class )
277
283
@ TestForIssue ( jiraKey = "HHH-5946" )
284
+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
278
285
public void testGreaterOrEqualOperator () {
279
286
final Session s = openSession ();
280
- s . getTransaction (). begin ();
281
-
282
- final Query q = s . createQuery ( "from Transaction where value >= :amount" );
283
- q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "USD" ) ) );
284
- q . list ();
285
-
286
- s . getTransaction (). commit ();
287
- s . close ();
287
+ try {
288
+ final Query q = s . createQuery ( "from Transaction where value >= :amount" );
289
+ q . setParameter ( "amount" , new MonetoryAmount ( BigDecimal . ZERO , Currency . getInstance ( "USD" ) ) );
290
+ q . list ( );
291
+ }
292
+ finally {
293
+ s . close ();
294
+ }
288
295
}
289
296
290
297
}
0 commit comments