diff --git a/hibernate-core/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java index e4569f966c..08b8868d8e 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java @@ -18,6 +18,9 @@ import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.hql.internal.ast.QuerySyntaxException; + +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.TestForIssue; @@ -221,16 +224,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { */ @Test( expected = QuerySyntaxException.class ) @TestForIssue( jiraKey = "HHH-5946" ) + @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) public void testLessThanOperator() { final Session s = openSession(); - s.getTransaction().begin(); - - final Query q = s.createQuery( "from Transaction where value < :amount" ); - q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); - q.list(); - - s.getTransaction().commit(); - s.close(); + try { + final Query q = s.createQuery( "from Transaction where value < :amount" ); + q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); + q.list(); + } + finally { + s.close(); + } } /** @@ -239,16 +243,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { */ @Test( expected = QuerySyntaxException.class ) @TestForIssue( jiraKey = "HHH-5946" ) + @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) public void testLessOrEqualOperator() { final Session s = openSession(); - s.getTransaction().begin(); - - final Query q = s.createQuery( "from Transaction where value <= :amount" ); - q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); - q.list(); - - s.getTransaction().commit(); - s.close(); + try { + final Query q = s.createQuery( "from Transaction where value <= :amount" ); + q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); + q.list(); + } + finally { + s.close(); + } } /** @@ -257,16 +262,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { */ @Test( expected = QuerySyntaxException.class ) @TestForIssue( jiraKey = "HHH-5946" ) + @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) public void testGreaterThanOperator() { final Session s = openSession(); - s.getTransaction().begin(); - - final Query q = s.createQuery( "from Transaction where value > :amount" ); - q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); - q.list(); - - s.getTransaction().commit(); - s.close(); + try { + final Query q = s.createQuery( "from Transaction where value > :amount" ); + q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); + q.list(); + } + finally { + s.close(); + } } /** @@ -275,16 +281,17 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { */ @Test( expected = QuerySyntaxException.class ) @TestForIssue( jiraKey = "HHH-5946" ) + @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) public void testGreaterOrEqualOperator() { final Session s = openSession(); - s.getTransaction().begin(); - - final Query q = s.createQuery( "from Transaction where value >= :amount" ); - q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); - q.list(); - - s.getTransaction().commit(); - s.close(); + try { + final Query q = s.createQuery( "from Transaction where value >= :amount" ); + q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); + q.list(); + } + finally { + s.close(); + } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/cut/Transaction.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cut/Transaction.hbm.xml index 343822b8b0..96f5aaae2e 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/cut/Transaction.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/test/cut/Transaction.hbm.xml @@ -27,12 +27,12 @@ - - - - - - + + + + + + diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java b/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java index ab4ebf60bd..94a5f72f95 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java @@ -177,4 +177,10 @@ abstract public class DialectChecks { return dialect.canCreateCatalog(); } } + + public static class DoesNotSupportRowValueConstructorSyntax implements DialectCheck { + public boolean isMatch(Dialect dialect) { + return dialect.supportsRowValueConstructorSyntax() == false; + } + } }