1818import org .hibernate .dialect .HSQLDialect ;
1919import org .hibernate .dialect .SybaseASE15Dialect ;
2020import org .hibernate .hql .internal .ast .QuerySyntaxException ;
21+
22+ import org .hibernate .testing .DialectChecks ;
23+ import org .hibernate .testing .RequiresDialectFeature ;
2124import org .hibernate .testing .SkipForDialect ;
2225import org .hibernate .testing .SkipForDialects ;
2326import org .hibernate .testing .TestForIssue ;
@@ -221,16 +224,17 @@ public void testNotEqualOperator() {
221224 */
222225 @ Test ( expected = QuerySyntaxException .class )
223226 @ TestForIssue ( jiraKey = "HHH-5946" )
227+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
224228 public void testLessThanOperator () {
225229 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+ }
234238 }
235239
236240 /**
@@ -239,16 +243,17 @@ public void testLessThanOperator() {
239243 */
240244 @ Test ( expected = QuerySyntaxException .class )
241245 @ TestForIssue ( jiraKey = "HHH-5946" )
246+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
242247 public void testLessOrEqualOperator () {
243248 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+ }
252257 }
253258
254259 /**
@@ -257,16 +262,17 @@ public void testLessOrEqualOperator() {
257262 */
258263 @ Test ( expected = QuerySyntaxException .class )
259264 @ TestForIssue ( jiraKey = "HHH-5946" )
265+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
260266 public void testGreaterThanOperator () {
261267 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+ }
270276 }
271277
272278 /**
@@ -275,16 +281,17 @@ public void testGreaterThanOperator() {
275281 */
276282 @ Test ( expected = QuerySyntaxException .class )
277283 @ TestForIssue ( jiraKey = "HHH-5946" )
284+ @ RequiresDialectFeature ( value = DialectChecks .DoesNotSupportRowValueConstructorSyntax .class )
278285 public void testGreaterOrEqualOperator () {
279286 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+ }
288295 }
289296
290297}
0 commit comments