From ff59a1301d351639d7e3e6e19d046b3f34af82cc Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 16 Jul 2019 16:00:58 +0100 Subject: [PATCH] 6 - SQM based on JPA type system --- .../test/cut/CompositeUserTypeTest.java | 374 +++++++++--------- ...atedCompositeIdResultSetProcessorTest.java | 1 + ...atedCompositeIdResultSetProcessorTest.java | 1 + .../hibernate/test/legacy/ABCProxyTest.java | 0 .../test/legacy/ComponentNotNullTest.java | 0 .../hibernate/test/legacy/CustomSQLTest.java | 1 - .../org/hibernate/test/legacy/FooBarTest.java | 0 .../org/hibernate/test/legacy/FumTest.java | 0 .../org/hibernate/test/legacy/IJ2Test.java | 0 .../org/hibernate/test/legacy/IJTest.java | 0 .../hibernate/test/legacy/LegacyTestCase.java | 0 .../org/hibernate/test/legacy/MapTest.java | 0 .../test/legacy/MasterDetailTest.java | 0 .../hibernate/test/legacy/MultiTableTest.java | 0 .../test/legacy/OneToOneCacheTest.java | 0 .../test/legacy/ParentChildTest.java | 0 .../test/legacy/QueryByExampleTest.java | 0 .../test/legacy/SQLFunctionsTest.java | 2 - .../hibernate/test/legacy/SQLLoaderTest.java | 0 .../hibernate/test/legacy/StatisticsTest.java | 0 20 files changed, 197 insertions(+), 182 deletions(-) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/ABCProxyTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/ComponentNotNullTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/CustomSQLTest.java (99%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/FooBarTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/FumTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/IJ2Test.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/IJTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/LegacyTestCase.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/MapTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/MasterDetailTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/MultiTableTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/OneToOneCacheTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/ParentChildTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/QueryByExampleTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/SQLFunctionsTest.java (99%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/SQLLoaderTest.java (100%) rename hibernate-core/src/{test/java => test_legacy}/org/hibernate/test/legacy/StatisticsTest.java (100%) 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 bd5315b51e..3f31d45099 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 @@ -9,14 +9,16 @@ package org.hibernate.test.cut; import java.math.BigDecimal; import java.util.Currency; import java.util.List; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; -import org.hibernate.query.Query; import org.hibernate.Session; -import org.hibernate.criterion.Restrictions; 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.query.Query; +import org.hibernate.query.SemanticException; import org.hibernate.testing.DialectChecks; import org.hibernate.testing.RequiresDialectFeature; @@ -39,183 +41,213 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { @Test public void testCompositeUserType() { - Session s = openSession(); - org.hibernate.Transaction t = s.beginTransaction(); - - Transaction tran = new Transaction(); - tran.setDescription("a small transaction"); - tran.setValue( new MonetoryAmount( new BigDecimal(1.5), Currency.getInstance("USD") ) ); - s.persist(tran); - - List result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'USD'").list(); - assertEquals( result.size(), 1 ); - tran.getValue().setCurrency( Currency.getInstance("AUD") ); - result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'AUD'").list(); - assertEquals( result.size(), 1 ); - - if ( !(getDialect() instanceof HSQLDialect) ) { - - result = s.createQuery("from Transaction txn where txn.value = (1.5, 'AUD')").list(); - assertEquals( result.size(), 1 ); - result = s.createQuery("from Transaction where value = (1.5, 'AUD')").list(); - assertEquals( result.size(), 1 ); - result = s.createQuery( "from Transaction where value != (1.4, 'AUD')" ).list(); - assertEquals( result.size(), 1 ); - } - - s.delete(tran); - t.commit(); - s.close(); - } - - @Test - @SkipForDialect ( value = { SybaseASE15Dialect.class }, jiraKey = "HHH-6788" ) - @SkipForDialect ( value = { DB2Dialect.class }, jiraKey = "HHH-6867" ) - public void testCustomColumnReadAndWrite() { - Session s = openSession(); - org.hibernate.Transaction t = s.beginTransaction(); - final BigDecimal AMOUNT = new BigDecimal(73000000d); - final BigDecimal AMOUNT_MILLIONS = AMOUNT.divide(new BigDecimal(1000000d)); - MutualFund f = new MutualFund(); - f.setHoldings( new MonetoryAmount( AMOUNT, Currency.getInstance("USD") ) ); - s.persist(f); - s.flush(); + inTransaction( + s -> { + Transaction tran = new Transaction(); + tran.setDescription( "a small transaction" ); + tran.setValue( new MonetoryAmount( new BigDecimal( 1.5 ), Currency.getInstance( "USD" ) ) ); + s.persist( tran ); - // Test value conversion during insert - BigDecimal amountViaSql = (BigDecimal)s.createSQLQuery("select amount_millions from MutualFund").uniqueResult(); - assertEquals(AMOUNT_MILLIONS.doubleValue(), amountViaSql.doubleValue(), 0.01d); - - // Test projection - BigDecimal amountViaHql = (BigDecimal)s.createQuery("select f.holdings.amount from MutualFund f").uniqueResult(); - assertEquals(AMOUNT.doubleValue(), amountViaHql.doubleValue(), 0.01d); - - // Test restriction and entity load via criteria - BigDecimal one = new BigDecimal(1); - f = (MutualFund)s.createCriteria(MutualFund.class) - .add(Restrictions.between("holdings.amount", AMOUNT.subtract(one), AMOUNT.add(one))) - .uniqueResult(); - assertEquals(AMOUNT.doubleValue(), f.getHoldings().getAmount().doubleValue(), 0.01d); - - // Test predicate and entity load via HQL - f = (MutualFund)s.createQuery("from MutualFund f where f.holdings.amount between ?1 and ?2") - .setBigDecimal(1, AMOUNT.subtract(one)) - .setBigDecimal(2, AMOUNT.add(one)) - .uniqueResult(); - assertEquals(AMOUNT.doubleValue(), f.getHoldings().getAmount().doubleValue(), 0.01d); - - s.delete(f); - t.commit(); - s.close(); - + List result = s.createQuery( + "from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'USD'" ) + .list(); + assertEquals( result.size(), 1 ); + tran.getValue().setCurrency( Currency.getInstance( "AUD" ) ); + result = s.createQuery( + "from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'AUD'" ) + .list(); + assertEquals( result.size(), 1 ); + + if ( !( getDialect() instanceof HSQLDialect ) ) { + + result = s.createQuery( "from Transaction txn where txn.value = (1.5, 'AUD')" ).list(); + assertEquals( result.size(), 1 ); + result = s.createQuery( "from Transaction where value = (1.5, 'AUD')" ).list(); + assertEquals( result.size(), 1 ); + result = s.createQuery( "from Transaction where value != (1.4, 'AUD')" ).list(); + assertEquals( result.size(), 1 ); + } + + s.delete( tran ); + } + ); + } + + @Test + @SkipForDialect(value = { SybaseASE15Dialect.class }, jiraKey = "HHH-6788") + @SkipForDialect(value = { DB2Dialect.class }, jiraKey = "HHH-6867") + public void testCustomColumnReadAndWrite() { + inTransaction( + s -> { + final BigDecimal AMOUNT = new BigDecimal( 73000000d ); + final BigDecimal AMOUNT_MILLIONS = AMOUNT.divide( new BigDecimal( 1000000d ) ); + MutualFund f = new MutualFund(); + f.setHoldings( new MonetoryAmount( AMOUNT, Currency.getInstance( "USD" ) ) ); + s.persist( f ); + s.flush(); + + // Test value conversion during insert + BigDecimal amountViaSql = (BigDecimal) s.createNativeQuery( "select amount_millions from MutualFund" ) + .uniqueResult(); + assertEquals( AMOUNT_MILLIONS.doubleValue(), amountViaSql.doubleValue(), 0.01d ); + + // Test projection + BigDecimal amountViaHql = (BigDecimal) s.createQuery( "select f.holdings.amount from MutualFund f" ) + .uniqueResult(); + assertEquals( AMOUNT.doubleValue(), amountViaHql.doubleValue(), 0.01d ); + + // Test restriction and entity load via criteria + BigDecimal one = new BigDecimal( 1 ); + + CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder(); + CriteriaQuery criteria = criteriaBuilder.createQuery( MutualFund.class ); + Root root = criteria.from( MutualFund.class ); + criteria.where( criteriaBuilder.between( + root.get( "holdings" ).get( "amount" ), + AMOUNT.subtract( one ), + AMOUNT.add( one ) + ) ); + f = s.createQuery( criteria ).uniqueResult(); +// f = (MutualFund)s.createCriteria(MutualFund.class) +// .add(Restrictions.between("holdings.amount", AMOUNT.subtract(one), AMOUNT.add(one))) +// .uniqueResult(); + assertEquals( AMOUNT.doubleValue(), f.getHoldings().getAmount().doubleValue(), 0.01d ); + + // Test predicate and entity load via HQL + f = (MutualFund) s.createQuery( "from MutualFund f where f.holdings.amount between ?1 and ?2" ) + .setParameter( 1, AMOUNT.subtract( one ) ) + .setParameter( 2, AMOUNT.add( one ) ) + .uniqueResult(); + assertEquals( AMOUNT.doubleValue(), f.getHoldings().getAmount().doubleValue(), 0.01d ); + + s.delete( f ); + } + ); } /** * Tests the {@code =} operator on composite types. */ public void testEqualOperator() { - final Session s = openSession(); - s.getTransaction().begin(); + inTransaction( + s -> { + final Transaction txn = new Transaction(); + txn.setDescription( "foo" ); + txn.setValue( new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "AUD" ) ) ); + txn.setTimestamp( new CompositeDateTime( 2014, 8, 23, 14, 35, 0 ) ); + s.persist( txn ); - final Transaction txn = new Transaction(); - txn.setDescription( "foo" ); - txn.setValue( new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "AUD" ) ) ); - txn.setTimestamp( new CompositeDateTime( 2014, 8, 23, 14, 35, 0 ) ); - s.persist( txn ); + final Query q = s.createQuery( "from Transaction where value = :amount" ); - final Query q = s.createQuery( "from Transaction where value = :amount" ); + /* Both amount and currency match. */ + q.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "AUD" ) ) + ); + assertEquals( 1, q.list().size() ); - /* Both amount and currency match. */ - q.setParameter( "amount", new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "AUD" ) ) ); - assertEquals( 1, q.list().size() ); + /* Only currency matches. */ + q.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 36 ), Currency.getInstance( "AUD" ) ) + ); + assertEquals( 0, q.list().size() ); - /* Only currency matches. */ - q.setParameter( "amount", new MonetoryAmount( new BigDecimal( 36 ), Currency.getInstance( "AUD" ) ) ); - assertEquals( 0, q.list().size() ); + /* Only amount matches. */ + q.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "EUR" ) ) + ); + assertEquals( 0, q.list().size() ); - /* Only amount matches. */ - q.setParameter( "amount", new MonetoryAmount( new BigDecimal( 42 ), Currency.getInstance( "EUR" ) ) ); - assertEquals( 0, q.list().size() ); + /* None match. */ + q.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 76 ), Currency.getInstance( "USD" ) ) + ); + assertEquals( 0, q.list().size() ); - /* None match. */ - q.setParameter( "amount", new MonetoryAmount( new BigDecimal( 76 ), Currency.getInstance( "USD" ) ) ); - assertEquals( 0, q.list().size() ); + final Query qTimestamp = s.createQuery( "from Transaction where timestamp = :timestamp" ); - final Query qTimestamp = s.createQuery( "from Transaction where timestamp = :timestamp" ); + /* All matches. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 35, 0 ) ); + assertEquals( 1, qTimestamp.list().size() ); - /* All matches. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 35, 0 ) ); - assertEquals( 1, qTimestamp.list().size() ); + /* None matches. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2013, 9, 25, 12, 31, 25 ) ); + assertEquals( 0, qTimestamp.list().size() ); - /* None matches. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2013, 9, 25, 12, 31, 25 ) ); - assertEquals( 0, qTimestamp.list().size() ); + /* Year doesn't match. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2013, 8, 23, 14, 35, 0 ) ); + assertEquals( 0, qTimestamp.list().size() ); - /* Year doesn't match. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2013, 8, 23, 14, 35, 0 ) ); - assertEquals( 0, qTimestamp.list().size() ); + /* Month doesn't match. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 9, 23, 14, 35, 0 ) ); + assertEquals( 0, qTimestamp.list().size() ); - /* Month doesn't match. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 9, 23, 14, 35, 0 ) ); - assertEquals( 0, qTimestamp.list().size() ); + /* Minute doesn't match. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 41, 0 ) ); + assertEquals( 0, qTimestamp.list().size() ); - /* Minute doesn't match. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 41, 0 ) ); - assertEquals( 0, qTimestamp.list().size() ); + /* Second doesn't match. */ + qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 35, 28 ) ); + assertEquals( 0, qTimestamp.list().size() ); - /* Second doesn't match. */ - qTimestamp.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 35, 28 ) ); - assertEquals( 0, qTimestamp.list().size() ); - - s.delete( txn ); - s.getTransaction().commit(); - s.close(); + s.delete( txn ); + } + ); } /** * Tests the {@code <>} operator on composite types. */ @Test - @TestForIssue( jiraKey = "HHH-5946" ) + @TestForIssue(jiraKey = "HHH-5946") public void testNotEqualOperator() { - final Session s = openSession(); - s.getTransaction().begin(); + inTransaction( + s -> { + final Transaction t1 = new Transaction(); + t1.setDescription( "foo" ); + t1.setValue( new MonetoryAmount( new BigDecimal( 178 ), Currency.getInstance( "EUR" ) ) ); + t1.setTimestamp( new CompositeDateTime( 2014, 8, 23, 14, 23, 0 ) ); + s.persist( t1 ); - final Transaction t1 = new Transaction(); - t1.setDescription( "foo" ); - t1.setValue( new MonetoryAmount( new BigDecimal( 178 ), Currency.getInstance( "EUR" ) ) ); - t1.setTimestamp( new CompositeDateTime( 2014, 8, 23, 14, 23, 0 ) ); - s.persist( t1 ); + final Transaction t2 = new Transaction(); + t2.setDescription( "bar" ); + t2.setValue( new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "USD" ) ) ); + t1.setTimestamp( new CompositeDateTime( 2014, 8, 22, 14, 23, 0 ) ); + s.persist( t2 ); - final Transaction t2 = new Transaction(); - t2.setDescription( "bar" ); - t2.setValue( new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "USD" ) ) ); - t1.setTimestamp( new CompositeDateTime( 2014, 8, 22, 14, 23, 0 ) ); - s.persist( t2 ); + final Transaction t3 = new Transaction(); + t3.setDescription( "bar" ); + t3.setValue( new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "EUR" ) ) ); + t3.setTimestamp( new CompositeDateTime( 2014, 8, 22, 14, 23, 01 ) ); + s.persist( t3 ); - final Transaction t3 = new Transaction(); - t3.setDescription( "bar" ); - t3.setValue( new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "EUR" ) ) ); - t3.setTimestamp( new CompositeDateTime( 2014, 8, 22, 14, 23, 01 ) ); - s.persist( t3 ); + final Query q1 = s.createQuery( "from Transaction where value <> :amount" ); + q1.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 178 ), Currency.getInstance( "EUR" ) ) + ); + assertEquals( 2, q1.list().size() ); - final Query q1 = s.createQuery( "from Transaction where value <> :amount" ); - q1.setParameter( "amount", new MonetoryAmount( new BigDecimal( 178 ), Currency.getInstance( "EUR" ) ) ); - assertEquals( 2, q1.list().size() ); + final Query q2 = s.createQuery( "from Transaction where value <> :amount and description = :str" ); + q2.setParameter( + "amount", + new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "USD" ) ) + ); + q2.setParameter( "str", "bar" ); + assertEquals( 1, q2.list().size() ); - final Query q2 = s.createQuery( "from Transaction where value <> :amount and description = :str" ); - q2.setParameter( "amount", new MonetoryAmount( new BigDecimal( 1000000 ), Currency.getInstance( "USD" ) ) ); - q2.setParameter( "str", "bar" ); - assertEquals( 1, q2.list().size() ); + final Query q3 = s.createQuery( "from Transaction where timestamp <> :timestamp" ); + q3.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 23, 0 ) ); + assertEquals( 2, q3.list().size() ); - final Query q3 = s.createQuery( "from Transaction where timestamp <> :timestamp" ); - q3.setParameter( "timestamp", new CompositeDateTime( 2014, 8, 23, 14, 23, 0 ) ); - assertEquals( 2, q3.list().size() ); - - s.delete( t3 ); - s.delete( t2 ); - s.delete( t1 ); - s.getTransaction().commit(); - s.close(); + s.delete( t3 ); + s.delete( t2 ); + s.delete( t1 ); + } + ); } /** @@ -223,22 +255,18 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { * rather than create a random query. */ @Test - @TestForIssue( jiraKey = "HHH-5946" ) - @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) + @TestForIssue(jiraKey = "HHH-5946") + @RequiresDialectFeature(value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class) public void testLessThanOperator() { - final Session s = openSession(); - try { + try (Session s = openSession()) { final Query q = s.createQuery( "from Transaction where value < :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); q.list(); } catch (IllegalArgumentException e) { - assertTyping( QuerySyntaxException.class, e.getCause() ); + assertTyping( SemanticException.class, e.getCause() ); //expected } - finally { - s.close(); - } } /** @@ -246,22 +274,18 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { * rather than create a random query. */ @Test - @TestForIssue( jiraKey = "HHH-5946" ) - @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) + @TestForIssue(jiraKey = "HHH-5946") + @RequiresDialectFeature(value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class) public void testLessOrEqualOperator() { - final Session s = openSession(); - try { + try (Session s = openSession()) { final Query q = s.createQuery( "from Transaction where value <= :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); q.list(); } catch (IllegalArgumentException e) { - assertTyping( QuerySyntaxException.class, e.getCause() ); + assertTyping( SemanticException.class, e.getCause() ); //expected } - finally { - s.close(); - } } /** @@ -269,22 +293,18 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { * rather than create a random query. */ @Test - @TestForIssue( jiraKey = "HHH-5946" ) - @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) + @TestForIssue(jiraKey = "HHH-5946") + @RequiresDialectFeature(value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class) public void testGreaterThanOperator() { - final Session s = openSession(); - try { + try (Session s = openSession()) { final Query q = s.createQuery( "from Transaction where value > :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "EUR" ) ) ); q.list(); } catch (IllegalArgumentException e) { - assertTyping( QuerySyntaxException.class, e.getCause() ); + assertTyping( SemanticException.class, e.getCause() ); //expected } - finally { - s.close(); - } } /** @@ -292,22 +312,18 @@ public class CompositeUserTypeTest extends BaseCoreFunctionalTestCase { * rather than create a random query. */ @Test - @TestForIssue( jiraKey = "HHH-5946" ) - @RequiresDialectFeature( value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class ) + @TestForIssue(jiraKey = "HHH-5946") + @RequiresDialectFeature(value = DialectChecks.DoesNotSupportRowValueConstructorSyntax.class) public void testGreaterOrEqualOperator() { - final Session s = openSession(); - try { + try (Session s = openSession()) { final Query q = s.createQuery( "from Transaction where value >= :amount" ); q.setParameter( "amount", new MonetoryAmount( BigDecimal.ZERO, Currency.getInstance( "USD" ) ) ); q.list(); } catch (IllegalArgumentException e) { - assertTyping( QuerySyntaxException.class, e.getCause() ); + assertTyping( SemanticException.class, e.getCause() ); //expected } - finally { - s.close(); - } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/EncapsulatedCompositeIdResultSetProcessorTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/EncapsulatedCompositeIdResultSetProcessorTest.java index bfa44c2555..80247be2c3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/EncapsulatedCompositeIdResultSetProcessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/EncapsulatedCompositeIdResultSetProcessorTest.java @@ -21,6 +21,7 @@ import javax.persistence.ManyToOne; import org.hibernate.LockOptions; import org.hibernate.Session; +import org.hibernate.engine.spi.QueryParameters; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jdbc.Work; import org.hibernate.loader.plan.exec.process.spi.ResultSetProcessor; diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java index a84bc62ff3..a62baae97c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java @@ -16,6 +16,7 @@ import java.util.List; import org.hibernate.LockOptions; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.engine.spi.QueryParameters; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jdbc.Work; import org.hibernate.loader.plan.exec.process.spi.ResultSetProcessor; diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/ABCProxyTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/ABCProxyTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/ABCProxyTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/ABCProxyTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/ComponentNotNullTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/ComponentNotNullTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/ComponentNotNullTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/ComponentNotNullTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/CustomSQLTest.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/CustomSQLTest.java index 3bd02fc963..b223652f2d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/CustomSQLTest.java @@ -17,7 +17,6 @@ import org.hibernate.Session; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.PostgreSQLDialect; -import org.hibernate.id.PostInsertIdentifierGenerator; import org.hibernate.testing.DialectCheck; import org.hibernate.testing.RequiresDialectFeature; diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FooBarTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/FooBarTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FumTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/FumTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/FumTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/IJ2Test.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/IJ2Test.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/IJ2Test.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/IJ2Test.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/IJTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/IJTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/IJTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/IJTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/LegacyTestCase.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/LegacyTestCase.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/LegacyTestCase.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/LegacyTestCase.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/MapTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/MapTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/MapTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/MapTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/MasterDetailTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/MasterDetailTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/MasterDetailTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/MultiTableTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/MultiTableTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/MultiTableTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/MultiTableTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/OneToOneCacheTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/OneToOneCacheTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/ParentChildTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/ParentChildTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/ParentChildTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/ParentChildTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/QueryByExampleTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/QueryByExampleTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/QueryByExampleTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/SQLFunctionsTest.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/SQLFunctionsTest.java index f8405a1bbb..ca1c91809a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java +++ b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/SQLFunctionsTest.java @@ -37,8 +37,6 @@ import org.hibernate.dialect.function.SQLFunction; import org.junit.Test; -import org.jboss.logging.Logger; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/SQLLoaderTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/SQLLoaderTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/SQLLoaderTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/StatisticsTest.java b/hibernate-core/src/test_legacy/org/hibernate/test/legacy/StatisticsTest.java similarity index 100% rename from hibernate-core/src/test/java/org/hibernate/test/legacy/StatisticsTest.java rename to hibernate-core/src/test_legacy/org/hibernate/test/legacy/StatisticsTest.java