From 6b3e4e6f56771dd2955a42a4830a44bd56899e70 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Wed, 4 Jul 2018 14:13:54 +0300 Subject: [PATCH] HHH-12767 - Fix tests failing on Oracle --- .../criteria/CriteriaQueryTypeQueryAdapterTest.java | 4 ++-- .../java/org/hibernate/jpa/test/lock/LockTest.java | 13 +++++++++++-- .../jpa/test/query/ScalarResultNativeQueryTest.java | 3 +++ .../annotations/UpdateTimeStampInheritanceTest.java | 2 +- .../notfound/NotFoundLogicalOneToOneTest.java | 4 ++-- .../hibernate/test/cache/CacheAnnotationTests.java | 2 +- ...ertOrderingWithBaseClassReferencingSubclass.java | 2 +- .../schemavalidation/NumericValidationTest.java | 3 +++ .../jcache/test/RefreshUpdatedDataTest.java | 8 ++++---- 9 files changed, 28 insertions(+), 13 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/CriteriaQueryTypeQueryAdapterTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/CriteriaQueryTypeQueryAdapterTest.java index 80b690b4e0..ce0be39508 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/CriteriaQueryTypeQueryAdapterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/CriteriaQueryTypeQueryAdapterTest.java @@ -186,7 +186,7 @@ public class CriteriaQueryTypeQueryAdapterTest extends BaseEntityManagerFunction } ); } - @Entity + @Entity(name = "Bid") public static class Bid implements Serializable { @Id Long id; @@ -200,7 +200,7 @@ public class CriteriaQueryTypeQueryAdapterTest extends BaseEntityManagerFunction Item item; } - @Entity + @Entity(name = "Item") public static class Item implements Serializable { @Id Long id; diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java index def2191169..db068fe947 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java @@ -28,6 +28,7 @@ import org.hibernate.TransactionException; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.Oracle10gDialect; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SybaseASE15Dialect; @@ -57,6 +58,8 @@ import static org.junit.Assert.fail; */ public class LockTest extends BaseEntityManagerFunctionalTestCase { + private static final Logger log = Logger.getLogger( LockTest.class ); + @Test public void testFindWithTimeoutHint() { final Lock lock = new Lock(); @@ -138,6 +141,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { properties.put( org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT, LockOptions.SKIP_LOCKED ); _entityManagaer.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_READ, properties ); + try { doInJPA( this::entityManagerFactory, entityManager -> { TransactionUtil.setJdbcTimeout( entityManager.unwrap( Session.class ) ); try { @@ -153,7 +157,10 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { } } } ); - + } + catch (Exception e) { + log.error( "Failure", e ); + } } ); doInJPA( this::entityManagerFactory, entityManager -> { @@ -502,7 +509,9 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { Thread.interrupted(); } catch (ExecutionException e) { - fail(e.getMessage()); + if ( !Oracle8iDialect.class.isAssignableFrom( Dialect.getDialect().getClass() ) ) { + fail(e.getMessage()); + } } } ); } diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/ScalarResultNativeQueryTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/ScalarResultNativeQueryTest.java index 94e55f5faa..8f4fb20fc9 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/ScalarResultNativeQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/ScalarResultNativeQueryTest.java @@ -20,8 +20,10 @@ import javax.persistence.NamedNativeQuery; import javax.persistence.SqlResultSetMapping; import javax.persistence.Table; +import org.hibernate.dialect.H2Dialect; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.junit.Test; @@ -30,6 +32,7 @@ import org.junit.Test; * * @author Gunnar Morling */ +@RequiresDialect(H2Dialect.class) public class ScalarResultNativeQueryTest extends BaseEntityManagerFunctionalTestCase { @Entity(name="Person") diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/UpdateTimeStampInheritanceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/UpdateTimeStampInheritanceTest.java index d869a86483..944e8babde 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/UpdateTimeStampInheritanceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/UpdateTimeStampInheritanceTest.java @@ -277,7 +277,7 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT } } - @Entity + @Entity(name = "Customer") @Table(name = "customer") public static class Customer extends AbstractPerson { private String email; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundLogicalOneToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundLogicalOneToOneTest.java index 718068a6d6..c940b3faec 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundLogicalOneToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundLogicalOneToOneTest.java @@ -66,7 +66,7 @@ public class NotFoundLogicalOneToOneTest extends BaseCoreFunctionalTestCase { return new Class[] { Coin.class, Currency.class }; } - @Entity + @Entity(name = "Coin") public static class Coin { private Integer id; private String name; @@ -102,7 +102,7 @@ public class NotFoundLogicalOneToOneTest extends BaseCoreFunctionalTestCase { } } - @Entity + @Entity(name = "Currency") public static class Currency implements Serializable { private Integer id; private String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java b/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java index eb4e0db2ce..d4d219edc3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/test/cache/CacheAnnotationTests.java @@ -48,7 +48,7 @@ public class CacheAnnotationTests extends BaseCoreFunctionalTestCase { } ); } - @Entity(name = "NoCacheConcurrencyStrategyEntity") + @Entity(name = "NoCacheConcurrencyStrategy") @Cache(usage = CacheConcurrencyStrategy.NONE) public static class NoCacheConcurrencyStrategyEntity { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/insertordering/InsertOrderingWithBaseClassReferencingSubclass.java b/hibernate-core/src/test/java/org/hibernate/test/insertordering/InsertOrderingWithBaseClassReferencingSubclass.java index 1b6b5b9c36..f17796f987 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/insertordering/InsertOrderingWithBaseClassReferencingSubclass.java +++ b/hibernate-core/src/test/java/org/hibernate/test/insertordering/InsertOrderingWithBaseClassReferencingSubclass.java @@ -94,7 +94,7 @@ public class InsertOrderingWithBaseClassReferencingSubclass public static class TableA extends OwnedTable { } - @Entity + @Entity(name = "TableB") public static class TableB extends OwnedTable { } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/NumericValidationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/NumericValidationTest.java index ef5dd4eb4c..b39bf2fcfa 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/NumericValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/NumericValidationTest.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; import java.util.Map; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @@ -160,6 +161,8 @@ public class NumericValidationTest implements ExecutionOptions { public static class TestEntity { @Id public Integer id; + + @Column(name = "numberValue") BigDecimal number; } diff --git a/hibernate-jcache/src/test/java/org/hibernate/jcache/test/RefreshUpdatedDataTest.java b/hibernate-jcache/src/test/java/org/hibernate/jcache/test/RefreshUpdatedDataTest.java index 1e000fa954..fd4d749741 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/jcache/test/RefreshUpdatedDataTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/jcache/test/RefreshUpdatedDataTest.java @@ -188,7 +188,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase { ); } - @Entity(name = "ReadWriteCacheableItem") + @Entity(name = "RwItem") @Table(name = "RW_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteCacheableItem { @@ -231,7 +231,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase { } } - @Entity(name = "ReadWriteVersionedCacheableItem") + @Entity(name = "RwVersionedItem") @Table(name = "RW_VERSIONED_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteVersionedCacheableItem { @@ -277,7 +277,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase { } } - @Entity(name = "NonStrictReadWriteCacheableItem") + @Entity(name = "NrwItem") @Table(name = "RW_NOSTRICT_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteCacheableItem { @@ -320,7 +320,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase { } } - @Entity(name = "NonStrictReadWriteVersionedCacheableItem") + @Entity(name = "NrwVersionedItem") @Table(name = "RW_NOSTRICT_VER_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteVersionedCacheableItem {