From e54ce7b2662d80eaa2ca4039921f51343e70dcb3 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 1 Mar 2017 13:47:27 +0000 Subject: [PATCH] HHH-11536 - Fix unit tests failing on Oracle --- .../ComponentInWhereClauseTest.java | 2 ++ ...SuperclassComponentWithCollectionTest.java | 2 ++ ...SuperclassComponentWithCollectionTest.java | 2 ++ .../org/hibernate/jpa/test/lock/LockTest.java | 3 +++ .../annotations/notfound/NotFoundTest.java | 3 +++ .../bytecode/enhancement/EnhancerTest.java | 3 +++ .../DetachedGetIdentifierTestTask.java | 2 +- .../lazy/cache/LazyInCacheTestTask.java | 6 ++--- .../converter/LongToDateConversionTest.java | 2 ++ .../flush/NonTransactionalDataAccessTest.java | 4 ++-- .../jdbc/internal/BasicConnectionTest.java | 22 +++++++++---------- .../org/hibernate/test/lob/LobStringTest.java | 3 +++ .../hibernate/test/lob/LongStringTest.java | 4 ++++ .../procedure/OracleStoredProcedureTest.java | 1 - .../hibernate/test/subquery/SubqueryTest.java | 7 +++--- .../SchemaToolTransactionHandlingTest.java | 18 ++++++++++----- .../test/type/TimeAndTimestampTest.java | 2 ++ .../functional/RefreshUpdatedDataTest.java | 5 +++++ .../collection/StringMapLobTest.java | 3 +++ .../StringMapNationalizedLobTest.java | 3 +++ .../hashcode/ListHashcodeChangeTest.java | 12 +++++----- .../hashcode/SetHashcodeChangeTest.java | 11 +++++----- .../ids/embeddedid/CorrectChildId.java | 1 + .../ids/embeddedid/IncorrectChildId.java | 2 ++ .../DiscriminatorJoinedInheritanceTest.java | 2 ++ .../HasChangedBidirectionalTest.java | 2 ++ .../multiplerelations/GroupMemberTest.java | 11 ++++++++-- .../MonotonicRevisionNumberTest.java | 2 +- .../update/SelectBeforeUpdateTest.java | 2 +- .../functional/RefreshUpdatedDataTest.java | 5 +++++ libraries.gradle | 1 - 31 files changed, 104 insertions(+), 44 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/ComponentInWhereClauseTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/ComponentInWhereClauseTest.java index 289d53f7a0..0750751544 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/ComponentInWhereClauseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/ComponentInWhereClauseTest.java @@ -7,6 +7,7 @@ package org.hibernate.jpa.test.criteria.components; import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Embeddable; import javax.persistence.Embedded; @@ -304,6 +305,7 @@ public class ComponentInWhereClauseTest extends BaseEntityManagerFunctionalTestC @Embeddable public static class Phone { + @Column(name = "phone_number") private String number; public Phone() { diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/EntitySuperclassComponentWithCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/EntitySuperclassComponentWithCollectionTest.java index 0bfb27607a..dbc4d58225 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/EntitySuperclassComponentWithCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/EntitySuperclassComponentWithCollectionTest.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Embeddable; import javax.persistence.Embedded; @@ -237,6 +238,7 @@ public class EntitySuperclassComponentWithCollectionTest extends BaseEntityManag @Embeddable public static class Phone { + @Column(name = "phone_number") private String number; public Phone() { diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/MappedSuperclassComponentWithCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/MappedSuperclassComponentWithCollectionTest.java index 017d9dcd4b..d870d2d5ad 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/MappedSuperclassComponentWithCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/components/MappedSuperclassComponentWithCollectionTest.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Embeddable; import javax.persistence.Embedded; @@ -236,6 +237,7 @@ public class MappedSuperclassComponentWithCollectionTest extends BaseEntityManag @Embeddable public static class Phone { + @Column(name = "phone_number") private String number; public Phone() { 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 17bd3ab74e..d2e6063349 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 @@ -31,6 +31,7 @@ import org.hibernate.jpa.QueryHints; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpected; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.SkipForDialect; @@ -719,6 +720,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { @Test @RequiresDialect( Oracle10gDialect.class ) @RequiresDialectFeature( DialectChecks.SupportsLockTimeouts.class ) + @FailureExpected( jiraKey = "HHH-8001" ) public void testQueryTimeout() throws Exception { EntityManager em = getOrCreateEntityManager(); @@ -812,6 +814,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { @Test @RequiresDialect( Oracle10gDialect.class ) @RequiresDialectFeature( DialectChecks.SupportsLockTimeouts.class ) + @FailureExpected( jiraKey = "HHH-8001" ) public void testQueryTimeoutEMProps() throws Exception { EntityManager em = getOrCreateEntityManager(); Map queryTimeoutProps = new HashMap(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundTest.java index 887e8ca3b9..d5f2f2eb7c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundTest.java @@ -19,6 +19,8 @@ import javax.persistence.OneToOne; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -28,6 +30,7 @@ import static org.junit.Assert.assertNull; /** * @author Emmanuel Bernard */ +@RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class) public class NotFoundTest extends BaseCoreFunctionalTestCase { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/EnhancerTest.java b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/EnhancerTest.java index 174aa1c6cc..a12176e146 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/EnhancerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/EnhancerTest.java @@ -10,7 +10,9 @@ import org.hibernate.bytecode.enhance.spi.UnloadedClass; import org.hibernate.test.bytecode.enhancement.detached.DetachedGetIdentifierTestTask; import org.hibernate.test.bytecode.enhancement.cascade.CascadeWithFkConstraintTestTask; +import org.hibernate.testing.DialectChecks; import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.bytecode.enhancement.EnhancerTestContext; import org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils; @@ -131,6 +133,7 @@ public class EnhancerTest extends BaseUnitTestCase { @Test @TestForIssue( jiraKey = "HHH-11173" ) + @RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class) public void testLazyCache() { EnhancerTestUtils.runEnhancerTestTask( LazyInCacheTestTask.class ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/detached/DetachedGetIdentifierTestTask.java b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/detached/DetachedGetIdentifierTestTask.java index 76a263900e..82f46c3f87 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/detached/DetachedGetIdentifierTestTask.java +++ b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/detached/DetachedGetIdentifierTestTask.java @@ -46,7 +46,7 @@ public class DetachedGetIdentifierTestTask extends AbstractEnhancerTestTask { protected void cleanup() { } - @Entity + @Entity(name = "SimpleEntity") public static class SimpleEntity { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/cache/LazyInCacheTestTask.java b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/cache/LazyInCacheTestTask.java index 38589e05f5..06fe90ad6b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/cache/LazyInCacheTestTask.java +++ b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/cache/LazyInCacheTestTask.java @@ -66,7 +66,7 @@ public class LazyInCacheTestTask extends AbstractEnhancerTestTask { protected void cleanup() { } - @Entity + @Entity(name = "Order") @Cache( usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE ) public static class Order { @@ -87,7 +87,7 @@ public class LazyInCacheTestTask extends AbstractEnhancerTestTask { } - @Entity + @Entity(name = "Product") public static class Product { @Id @@ -98,7 +98,7 @@ public class LazyInCacheTestTask extends AbstractEnhancerTestTask { } - @Entity + @Entity(name = "Tag") public class Tag { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/converter/LongToDateConversionTest.java b/hibernate-core/src/test/java/org/hibernate/test/converter/LongToDateConversionTest.java index f66d1569d3..13ca0c6573 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/converter/LongToDateConversionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/converter/LongToDateConversionTest.java @@ -7,6 +7,7 @@ package org.hibernate.test.converter; import javax.persistence.AttributeConverter; +import javax.persistence.Column; import javax.persistence.Convert; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -103,6 +104,7 @@ public class LongToDateConversionTest extends BaseCoreFunctionalTestCase { private long id; @Convert(converter = DateAttributeConverter.class) + @Column(name = "attribute_date") private DateAttribute date; public DateAttribute getDate() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/NonTransactionalDataAccessTest.java b/hibernate-core/src/test/java/org/hibernate/test/flush/NonTransactionalDataAccessTest.java index f42e050ea8..dc2592c981 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/flush/NonTransactionalDataAccessTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/flush/NonTransactionalDataAccessTest.java @@ -83,7 +83,7 @@ public class NonTransactionalDataAccessTest extends BaseCoreFunctionalTestCase { } @Test(expected = TransactionRequiredException.class) - public void testFlushDisallowingutOfTransactionUpdateOperations() throws Exception { + public void testFlushDisallowingOutOfTransactionUpdateOperations() throws Exception { allowUpdateOperationOutsideTransaction = "false"; rebuildSessionFactory(); prepareTest(); @@ -115,7 +115,7 @@ public class NonTransactionalDataAccessTest extends BaseCoreFunctionalTestCase { @Entity(name = "MyEntity") public static class MyEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue long id; String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/jdbc/internal/BasicConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/jdbc/internal/BasicConnectionTest.java index 9242a30a02..762bc1ead6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jdbc/internal/BasicConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jdbc/internal/BasicConnectionTest.java @@ -87,23 +87,21 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase { fail( "incorrect exception type : sqlexception" ); } finally { - session.close(); + try { + session.doWork( connection -> { + final Statement stmnt = connection.createStatement(); + + stmnt.execute( getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); + } ); + } + finally { + session.close(); + } } assertFalse( getResourceRegistry( jdbcCoord ).hasRegisteredResources() ); } - @Override - protected void cleanupTest() throws Exception { - try (Session session = openSession()) { - session.doWork( connection -> { - final Statement stmnt = connection.createStatement(); - - stmnt.execute( getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); - } ); - } - } - private ResourceRegistry getResourceRegistry(JdbcCoordinator jdbcCoord) { return jdbcCoord.getResourceRegistry(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/LobStringTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/LobStringTest.java index 359ba5c29c..c246ac4857 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/LobStringTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/LobStringTest.java @@ -16,9 +16,11 @@ import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Table; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.engine.jdbc.ClobProxy; import org.hibernate.query.Query; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.transaction.TransactionUtil; @@ -32,6 +34,7 @@ import static org.junit.Assert.fail; * @author Andrea Boriero */ @TestForIssue(jiraKey = "HHH-11477") +@SkipForDialect(Oracle8iDialect.class) public class LobStringTest extends BaseCoreFunctionalTestCase { private static final int LONG_STRING_SIZE = 10000; diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/LongStringTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/LongStringTest.java index 0989858253..0442ae075c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/LongStringTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/LongStringTest.java @@ -10,9 +10,11 @@ import java.util.List; import org.junit.Test; import org.hibernate.Session; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.query.Query; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.transaction.TransactionUtil; @@ -97,6 +99,7 @@ public abstract class LongStringTest extends BaseCoreFunctionalTestCase { } @Test + @SkipForDialect(Oracle8iDialect.class) @TestForIssue( jiraKey = "HHH-11477") public void testUsingLobPropertyInHqlQuery() { TransactionUtil.doInHibernate( this::sessionFactory, session -> { @@ -116,6 +119,7 @@ public abstract class LongStringTest extends BaseCoreFunctionalTestCase { } @Test + @SkipForDialect(Oracle8iDialect.class) @TestForIssue( jiraKey = "HHH-11477") public void testSelectLobPropertyInHqlQuery() { TransactionUtil.doInHibernate( this::sessionFactory, session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/test/procedure/OracleStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/test/procedure/OracleStoredProcedureTest.java index 5fc4688d03..d4de68669f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/procedure/OracleStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/procedure/OracleStoredProcedureTest.java @@ -303,7 +303,6 @@ public class OracleStoredProcedureTest extends BaseEntityManagerFunctionalTestCa } @Test - @FailureExpected( jiraKey = "HHH-10898") public void testNamedNativeQueryStoredProcedureRefCursor() { EntityManager entityManager = createEntityManager(); entityManager.getTransaction().begin(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/subquery/SubqueryTest.java b/hibernate-core/src/test/java/org/hibernate/test/subquery/SubqueryTest.java index d24c251cb0..2db18d4a1a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subquery/SubqueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subquery/SubqueryTest.java @@ -11,13 +11,12 @@ package org.hibernate.test.subquery; import org.hibernate.QueryException; import org.hibernate.Session; -import org.hibernate.dialect.MariaDBDialect; -import org.hibernate.dialect.PostgreSQL81Dialect; +import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.function.SQLFunction; import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.Type; import org.junit.Test; @@ -31,7 +30,7 @@ import java.util.function.Consumer; * * @author Christian Beikov */ -@SkipForDialect(value = MariaDBDialect.class, comment = "This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery") +@RequiresDialect(H2Dialect.class) public class SubqueryTest extends BaseCoreFunctionalTestCase { private static final SQLFunction LIMIT_FUNCTION = new SQLFunction() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/tool/schema/SchemaToolTransactionHandlingTest.java b/hibernate-core/src/test/java/org/hibernate/test/tool/schema/SchemaToolTransactionHandlingTest.java index 4369e0144a..a8e93d84db 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/tool/schema/SchemaToolTransactionHandlingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/tool/schema/SchemaToolTransactionHandlingTest.java @@ -6,6 +6,7 @@ */ package org.hibernate.test.tool.schema; +import java.sql.SQLSyntaxErrorException; import java.util.Collections; import java.util.EnumSet; import javax.persistence.Entity; @@ -22,6 +23,7 @@ import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoo import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; import org.hibernate.tool.schema.SourceType; import org.hibernate.tool.schema.TargetType; +import org.hibernate.tool.schema.spi.CommandAcceptanceException; import org.hibernate.tool.schema.spi.SchemaCreator; import org.hibernate.tool.schema.spi.SchemaDropper; import org.hibernate.tool.schema.spi.SchemaManagementTool; @@ -89,12 +91,16 @@ public class SchemaToolTransactionHandlingTest extends BaseUnitTestCase { final Metadata mappings = buildMappings( registry ); try { - schemaDropper.doDrop( - mappings, - ExecutionOptionsTestImpl.INSTANCE, - SourceDescriptorImpl.INSTANCE, - TargetDescriptorImpl.INSTANCE - ); + try { + schemaDropper.doDrop( + mappings, + ExecutionOptionsTestImpl.INSTANCE, + SourceDescriptorImpl.INSTANCE, + TargetDescriptorImpl.INSTANCE + ); + }catch (CommandAcceptanceException e){ + //ignore may happen if sql drop does not support if exist + } schemaCreator.doCreation( mappings, ExecutionOptionsTestImpl.INSTANCE, diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/TimeAndTimestampTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/TimeAndTimestampTest.java index 5394539256..6140193d00 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/TimeAndTimestampTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/TimeAndTimestampTest.java @@ -13,6 +13,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.Oracle9iDialect; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; @@ -27,6 +28,7 @@ import static org.junit.Assert.assertEquals; */ @TestForIssue(jiraKey = "HHH-10465") @SkipForDialect(MariaDBDialect.class) +@SkipForDialect(value = Oracle9iDialect.class, comment = "Oracle date does not support milliseconds ") public class TimeAndTimestampTest extends BaseNonConfigCoreFunctionalTestCase { @Override diff --git a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/functional/RefreshUpdatedDataTest.java b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/functional/RefreshUpdatedDataTest.java index d48956667e..a0a0725c3c 100644 --- a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/functional/RefreshUpdatedDataTest.java +++ b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/functional/RefreshUpdatedDataTest.java @@ -13,6 +13,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Table; import javax.persistence.Version; import org.hibernate.Session; @@ -173,6 +174,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "ReadWriteCacheableItem") + @Table(name = "RW_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteCacheableItem { @@ -215,6 +217,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "ReadWriteVersionedCacheableItem") + @Table(name = "RW_VERSIONED_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteVersionedCacheableItem { @@ -260,6 +263,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "NonStrictReadWriteCacheableItem") + @Table(name = "RW_NOSTRICT_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteCacheableItem { @@ -302,6 +306,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "NonStrictReadWriteVersionedCacheableItem") + @Table(name = "RW_NOSTRICT_VER_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteVersionedCacheableItem { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapLobTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapLobTest.java index d6fe34ba39..6342fe6192 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapLobTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapLobTest.java @@ -15,11 +15,13 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Lob; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.envers.Audited; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.tools.TestTools; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.transaction.TransactionUtil; import org.junit.Test; @@ -30,6 +32,7 @@ import static org.junit.Assert.assertEquals; * @author Chris Cranford */ @TestForIssue(jiraKey = "HHH-9834") +@SkipForDialect(Oracle8iDialect.class) public class StringMapLobTest extends BaseEnversJPAFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapNationalizedLobTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapNationalizedLobTest.java index be604f2add..7f13ddadc9 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapNationalizedLobTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/StringMapNationalizedLobTest.java @@ -16,11 +16,13 @@ import javax.persistence.Id; import javax.persistence.Lob; import org.hibernate.annotations.Nationalized; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.envers.Audited; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.tools.TestTools; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.transaction.TransactionUtil; import org.junit.Test; @@ -31,6 +33,7 @@ import static org.junit.Assert.assertEquals; * @author Chris Cranford */ @TestForIssue(jiraKey = "HHH-9834") +@SkipForDialect(Oracle8iDialect.class) public class StringMapNationalizedLobTest extends BaseEnversJPAFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/ListHashcodeChangeTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/ListHashcodeChangeTest.java index bb29a8da96..ba191e3c7a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/ListHashcodeChangeTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/ListHashcodeChangeTest.java @@ -12,12 +12,14 @@ import java.util.List; import java.util.Objects; import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; @@ -160,7 +162,7 @@ public class ListHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { return book; } - @Entity + @Entity(name = "Author") @Audited public static class Author { @Id @@ -171,8 +173,7 @@ public class ListHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { private String lastName; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "author_id", referencedColumnName = "id", nullable = false) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "author") private List books; public Integer getId() { @@ -244,7 +245,7 @@ public class ListHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { } } - @Entity + @Entity(name = "Book") @Audited public static class Book { @Id @@ -254,7 +255,8 @@ public class ListHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { private String title; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "author_id", nullable = false, insertable = false, updatable = false) + @JoinTable(name = "author_book", + joinColumns = @JoinColumn(name = "book_id"), inverseJoinColumns = @JoinColumn(name="author_id",nullable = false)) @NotAudited private Author author; diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/SetHashcodeChangeTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/SetHashcodeChangeTest.java index 5e6e4d9533..9f10c51194 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/SetHashcodeChangeTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/hashcode/SetHashcodeChangeTest.java @@ -19,6 +19,7 @@ import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; @@ -161,7 +162,7 @@ public class SetHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { return book; } - @Entity + @Entity(name = "Author") @Audited public static class Author { @Id @@ -172,8 +173,7 @@ public class SetHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { private String lastName; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "author_id", referencedColumnName = "id", nullable = false) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "author") private Set books; public Integer getId() { @@ -245,7 +245,7 @@ public class SetHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { } } - @Entity + @Entity(name = "Book") @Audited public static class Book { @Id @@ -255,7 +255,8 @@ public class SetHashcodeChangeTest extends BaseEnversJPAFunctionalTestCase { private String title; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "author_id", nullable = false, insertable = false, updatable = false) + @JoinTable(name = "author_book", + joinColumns = @JoinColumn(name = "book_id"), inverseJoinColumns = @JoinColumn(name="author_id",nullable = false)) @NotAudited private Author author; diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/CorrectChildId.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/CorrectChildId.java index 94e626512f..1855c48051 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/CorrectChildId.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/CorrectChildId.java @@ -19,6 +19,7 @@ public class CorrectChildId implements Serializable { @Column(name = "parent_id") private String id; + @Column(name = "child_number") private Integer number; CorrectChildId() { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/IncorrectChildId.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/IncorrectChildId.java index 3a541f3905..f2886a2809 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/IncorrectChildId.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/ids/embeddedid/IncorrectChildId.java @@ -8,6 +8,7 @@ package org.hibernate.envers.test.integration.ids.embeddedid; import java.io.Serializable; +import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; @@ -22,6 +23,7 @@ public class IncorrectChildId implements Serializable { @JoinColumns({ @JoinColumn(name = "parent_id", referencedColumnName = "id") }) private Parent parent; + @Column(name = "child_number") private Integer number; IncorrectChildId() { diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/inheritance/joined/DiscriminatorJoinedInheritanceTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/inheritance/joined/DiscriminatorJoinedInheritanceTest.java index e0c75492e4..6c49d042f0 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/inheritance/joined/DiscriminatorJoinedInheritanceTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/inheritance/joined/DiscriminatorJoinedInheritanceTest.java @@ -18,6 +18,7 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.OneToMany; +import javax.persistence.Table; import org.hibernate.envers.Audited; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; @@ -148,6 +149,7 @@ public class DiscriminatorJoinedInheritanceTest extends BaseEnversJPAFunctionalT } @Entity(name = "ChildListHolder") + @Table(name = "CHILD_HOLDER") @Audited public static class ChildListHolder { @Id diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/modifiedflags/HasChangedBidirectionalTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/modifiedflags/HasChangedBidirectionalTest.java index fd5bd3822d..b84417b8ab 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/modifiedflags/HasChangedBidirectionalTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/modifiedflags/HasChangedBidirectionalTest.java @@ -14,6 +14,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.Table; import org.hibernate.envers.Audited; import org.hibernate.envers.test.Priority; @@ -146,6 +147,7 @@ public class HasChangedBidirectionalTest extends AbstractModifiedFlagsEntityTest } @Entity(name = "Comment") + @Table(name = "COMMENTS") @Audited(withModifiedFlag = true) public static class Comment { @Id diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/multiplerelations/GroupMemberTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/multiplerelations/GroupMemberTest.java index 0461aeec8c..70d431b87d 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/multiplerelations/GroupMemberTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/multiplerelations/GroupMemberTest.java @@ -21,10 +21,14 @@ import javax.persistence.OneToMany; import javax.persistence.OrderColumn; import javax.persistence.Query; +import org.hibernate.Session; import org.hibernate.envers.AuditMappedBy; import org.hibernate.envers.Audited; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; +import org.hibernate.type.IntegerType; +import org.hibernate.type.Type; + import org.hibernate.testing.TestForIssue; import org.hibernate.testing.transaction.TransactionUtil; import org.junit.Test; @@ -83,8 +87,11 @@ public class GroupMemberTest extends BaseEnversJPAFunctionalTestCase { private Integer getCurrentAuditUniqueGroupId() { return TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { - final Query query = entityManager.createNativeQuery( - "SELECT uniqueGroup_id FROM GroupMember_AUD ORDER BY rev DESC" + final Session session = entityManager.unwrap( Session.class ); + final Query query = session.createSQLQuery( + "SELECT uniqueGroup_id FROM GroupMember_AUD ORDER BY rev DESC" ).addScalar( + "uniqueGroup_id", + IntegerType.INSTANCE ).setMaxResults( 1 ); final Object result = query.getSingleResult(); assertNotNull( result ); diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/reventity/MonotonicRevisionNumberTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/reventity/MonotonicRevisionNumberTest.java index dcb87e4d72..6b9274973d 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/reventity/MonotonicRevisionNumberTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/reventity/MonotonicRevisionNumberTest.java @@ -38,7 +38,7 @@ public class MonotonicRevisionNumberTest extends BaseEnversFunctionalTestCase { OrderedSequenceGenerator seqGenerator = (OrderedSequenceGenerator) generator; Assert.assertTrue( "Oracle sequence needs to be ordered in RAC environment.", - seqGenerator.sqlCreateStrings( getDialect() )[0].endsWith( " order" ) + seqGenerator.sqlCreateStrings( getDialect() )[0].toLowerCase().endsWith( " order" ) ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/update/SelectBeforeUpdateTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/update/SelectBeforeUpdateTest.java index 071de015ca..852209c99a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/update/SelectBeforeUpdateTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/update/SelectBeforeUpdateTest.java @@ -187,7 +187,7 @@ public class SelectBeforeUpdateTest extends BaseEnversFunctionalTestCase { } } - @Entity + @Entity(name = "Author") @Audited public static class Author { @Id diff --git a/hibernate-jcache/src/test/java/org/hibernate/test/cache/jcache/functional/RefreshUpdatedDataTest.java b/hibernate-jcache/src/test/java/org/hibernate/test/cache/jcache/functional/RefreshUpdatedDataTest.java index d2a652991c..e4eb75a8a0 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/test/cache/jcache/functional/RefreshUpdatedDataTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/test/cache/jcache/functional/RefreshUpdatedDataTest.java @@ -13,6 +13,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Table; import javax.persistence.Version; import org.hibernate.Session; @@ -173,6 +174,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "ReadWriteCacheableItem") + @Table(name = "RW_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteCacheableItem { @@ -215,6 +217,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "ReadWriteVersionedCacheableItem") + @Table(name = "RW_VERSIONED_ITEM") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") public static class ReadWriteVersionedCacheableItem { @@ -260,6 +263,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "NonStrictReadWriteCacheableItem") + @Table(name = "RW_NOSTRICT_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteCacheableItem { @@ -302,6 +306,7 @@ public class RefreshUpdatedDataTest extends BaseNonConfigCoreFunctionalTestCase } @Entity(name = "NonStrictReadWriteVersionedCacheableItem") + @Table(name = "RW_NOSTRICT_VER_ITEM") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") public static class NonStrictReadWriteVersionedCacheableItem { diff --git a/libraries.gradle b/libraries.gradle index 16a61ccfa3..4547c9870b 100644 --- a/libraries.gradle +++ b/libraries.gradle @@ -96,7 +96,6 @@ ext { postgresql: 'org.postgresql:postgresql:9.4-1202-jdbc41', mysql: 'mysql:mysql-connector-java:6.0.5', mariadb: 'org.mariadb.jdbc:mariadb-java-client:1.5.7', - oracle: 'com.oracle.jdbc:ojdbc7:12.1.0.2', oracle: 'com.oracle.ojdbc:ojdbc7:12.1.0.2.0', mssql: 'com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8',