From 231484662bbdf1d52453dae66c3df14814f757cb Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Tue, 26 Apr 2016 12:55:05 +0300 Subject: [PATCH] HHH-10689 - Fix tests failing when switching to Oracle --- .gitignore | 1 + build.gradle | 12 ++++++++ documentation/documentation.gradle | 13 ++++++++ .../DatabaseMultiTenancyTest.java | 2 +- .../multitenancy/SchemaMultiTenancyTest.java | 2 +- .../userguide/sql/CollectionLoaderTest.java | 12 ++++++-- .../sql/CustomSQLSecondaryTableTest.java | 5 ++++ .../userguide/sql/CustomSQLTest.java | 5 ++++ hibernate-core/hibernate-core.gradle | 2 -- .../EntitySuperclassCollectionTest.java | 23 +++++++++----- .../jpa/test/lock/QueryLockingTest.java | 18 ++++++----- .../hibernate/jpa/test/query/QueryTest.java | 6 ++-- .../indexcoll/IndexedCollectionTest.java | 19 ++++++------ .../eager/EagerIndexedCollectionTest.java | 2 +- .../hibernate/test/cid/CompositeIdTest.java | 7 +++++ .../map/MapKeyAttributeConverterTest.java | 10 +++---- .../InheritanceManyToManyForeignKeyTest.java | 6 ++-- .../test/hql/CriteriaHQLAlignmentTest.java | 3 ++ .../UUIDBasedIdInterpretationTest.java | 5 ++-- .../test/schemaupdate/SchemaExportTest.java | 7 +++-- .../SchemaUpdateFormatterTest.java | 7 +++-- .../CrossSchemaForeignKeyGenerationTest.java | 4 ++- .../hhh_x/InheritanceSchemaUpdateTest.java | 6 +++- .../test/sql/check/ResultCheckStyleTest.java | 30 +++++++++---------- .../src/test/resources/hibernate.properties | 3 +- .../integration/query/entities/Address.java | 3 ++ .../org/hibernate/testing/DialectChecks.java | 6 ++++ 27 files changed, 152 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index f4d9b9636d..8e96571a22 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /build */build testdb +lib # IntelliJ specific files/directories out diff --git a/build.gradle b/build.gradle index 07a97dacfb..8eecde2451 100644 --- a/build.gradle +++ b/build.gradle @@ -149,6 +149,18 @@ subprojects { subProject -> testRuntime( libraries.mariadb ) testRuntime( libraries.woodstox ) + if (db.equalsIgnoreCase("oracle")) { + dependencies { + testRuntime( libraries.oracle ) + } + } + + if (db.equalsIgnoreCase("mssql")) { + dependencies { + testRuntime( libraries.mssql ) + } + } + // 6.6 gave me some NPE problems from within checkstyle... checkstyle 'com.puppycrawl.tools:checkstyle:6.5' } diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index 5e6053059c..994149f2c2 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -73,6 +73,19 @@ dependencies { testRuntime( libraries.hsqldb ) testRuntime( libraries.postgresql ) testRuntime( libraries.mysql ) + testRuntime( libraries.mariadb ) + + if (db.equalsIgnoreCase("oracle")) { + dependencies { + testRuntime( libraries.oracle ) + } + } + + if (db.equalsIgnoreCase("mssql")) { + dependencies { + testRuntime( libraries.mssql ) + } + } } processTestResources.doLast( { diff --git a/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseMultiTenancyTest.java b/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseMultiTenancyTest.java index 9d67ed367b..40f73c8fdc 100644 --- a/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseMultiTenancyTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseMultiTenancyTest.java @@ -14,7 +14,7 @@ import org.hibernate.testing.RequiresDialect; /** * @author Vlad Mihalcea */ -@RequiresDialect( value = H2Dialect.class) +@RequiresDialect(H2Dialect.class) public class DatabaseMultiTenancyTest extends AbstractMultiTenancyTest { @Override diff --git a/documentation/src/test/java/org/hibernate/userguide/multitenancy/SchemaMultiTenancyTest.java b/documentation/src/test/java/org/hibernate/userguide/multitenancy/SchemaMultiTenancyTest.java index 54d4afd703..b066f28d9d 100644 --- a/documentation/src/test/java/org/hibernate/userguide/multitenancy/SchemaMultiTenancyTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/multitenancy/SchemaMultiTenancyTest.java @@ -14,7 +14,7 @@ import org.hibernate.testing.RequiresDialect; /** * @author Vlad Mihalcea */ -@RequiresDialect( value = H2Dialect.class) +@RequiresDialect(H2Dialect.class) public class SchemaMultiTenancyTest extends AbstractMultiTenancyTest { public static final String SCHEMA_TOKEN = ";INIT=CREATE SCHEMA IF NOT EXISTS %1$s\\;SET SCHEMA %1$s"; diff --git a/documentation/src/test/java/org/hibernate/userguide/sql/CollectionLoaderTest.java b/documentation/src/test/java/org/hibernate/userguide/sql/CollectionLoaderTest.java index b678973dfd..2280ee9ab7 100644 --- a/documentation/src/test/java/org/hibernate/userguide/sql/CollectionLoaderTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/sql/CollectionLoaderTest.java @@ -7,6 +7,7 @@ package org.hibernate.userguide.sql; import java.sql.Statement; +import java.sql.Types; import java.util.ArrayList; import java.util.List; import javax.persistence.ElementCollection; @@ -23,8 +24,12 @@ import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.RequiresDialects; import org.hibernate.testing.TestForIssue; import org.junit.Before; import org.junit.Test; @@ -39,6 +44,7 @@ import static org.junit.Assert.assertEquals; * * @author Vlad Mihalcea */ +@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)}) public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase { private static final Logger log = Logger.getLogger( CollectionLoaderTest.class ); @@ -56,8 +62,10 @@ public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase { Session session = entityManager.unwrap( Session.class ); session.doWork( connection -> { try(Statement statement = connection.createStatement(); ) { - statement.executeUpdate( "ALTER TABLE person ADD COLUMN valid boolean" ); - statement.executeUpdate( "ALTER TABLE Person_phones ADD COLUMN valid boolean" ); + statement.executeUpdate( String.format( "ALTER TABLE person %s valid %s", + getDialect().getAddColumnString(), getDialect().getTypeName( Types.BOOLEAN ))); + statement.executeUpdate( String.format( "ALTER TABLE Person_phones %s valid %s", + getDialect().getAddColumnString(), getDialect().getTypeName( Types.BOOLEAN ))); } } ); }); diff --git a/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLSecondaryTableTest.java b/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLSecondaryTableTest.java index 465b4bf40b..145f39a8e1 100644 --- a/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLSecondaryTableTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLSecondaryTableTest.java @@ -22,8 +22,12 @@ import org.hibernate.annotations.Loader; import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.RequiresDialects; import org.junit.Before; import org.junit.Test; @@ -36,6 +40,7 @@ import static org.junit.Assert.assertNull; /** * @author Vlad Mihalcea */ +@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)}) public class CustomSQLSecondaryTableTest extends BaseEntityManagerFunctionalTestCase { private static final Logger log = Logger.getLogger( CustomSQLSecondaryTableTest.class ); diff --git a/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLTest.java b/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLTest.java index 84bd28489a..7dea20eec0 100644 --- a/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/sql/CustomSQLTest.java @@ -24,8 +24,12 @@ import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; import org.hibernate.annotations.Where; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.RequiresDialects; import org.junit.Before; import org.junit.Test; @@ -38,6 +42,7 @@ import static org.junit.Assert.assertNull; /** * @author Vlad Mihalcea */ +@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)}) public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase { private static final Logger log = Logger.getLogger( CustomSQLTest.class ); diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index d01034c364..6606630275 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -164,8 +164,6 @@ xjc { //sourceSets.main.sourceGeneratorsTask.dependsOn generateGrammarSource tasks.compile.dependsOn generateGrammarSource - - task copyBundleResources (type: Copy) { ext.bundlesTargetDir = file( "${buildDir}/bundles" ) from file('src/test/bundles') diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/EntitySuperclassCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/EntitySuperclassCollectionTest.java index ed1cc3e9b7..265fd55b0c 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/EntitySuperclassCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/EntitySuperclassCollectionTest.java @@ -21,6 +21,7 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + import org.hibernate.testing.TestForIssue; import org.junit.Test; @@ -31,7 +32,8 @@ import static org.junit.Assert.assertEquals; * @author Janario Oliveira * @author Gail Badner */ -public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalTestCase { +public class EntitySuperclassCollectionTest + extends BaseEntityManagerFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { return new Class[] { @@ -40,7 +42,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT } @Test - @TestForIssue( jiraKey = "HHH-10556") + @TestForIssue(jiraKey = "HHH-10556") public void testPerson() { String address = "super-address"; @@ -50,10 +52,17 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT } private void assertAddress(PersonBase person, String address) { - List results = find( person.getClass(), person.id, "addresses" ); + List results = find( + person.getClass(), + person.id, + "addresses" + ); assertEquals( 1, results.size() ); - assertEquals( person.addresses.get( 0 ).id, ( (Address) results.get( 0 ) ).id ); + assertEquals( + person.addresses.get( 0 ).id, + ( (Address) results.get( 0 ) ).id + ); assertEquals( address, ( (Address) results.get( 0 ) ).name ); getOrCreateEntityManager().close(); @@ -83,7 +92,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT return query.getResultList(); } - @Entity(name="Address") + @Entity(name = "Address") public static class Address { @Id @GeneratedValue @@ -98,7 +107,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT } } - @Entity + @Entity(name = "PersonBase") public abstract static class PersonBase { @Id @GeneratedValue @@ -107,7 +116,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT List
addresses = new ArrayList
(); } - @Entity(name="Person") + @Entity(name = "Person") public static class Person extends PersonBase { } } diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/QueryLockingTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/QueryLockingTest.java index 9e974bdf76..386f8ef9da 100755 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/QueryLockingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/QueryLockingTest.java @@ -6,8 +6,16 @@ */ package org.hibernate.jpa.test.lock; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; import java.util.Map; + import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.Id; @@ -22,16 +30,11 @@ import org.hibernate.jpa.QueryHints; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.query.NativeQuery; +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.TestForIssue; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * @author Steve Ebersole */ @@ -327,6 +330,7 @@ public class QueryLockingTest extends BaseEntityManagerFunctionalTestCase { * lock some entities via a query and check the resulting lock mode type via EntityManager */ @Test + @RequiresDialectFeature( value = DialectChecks.DoesNotSupportFollowOnLocking.class) public void testEntityLockModeStateAfterQueryLocking() { // Create some test data EntityManager em = getOrCreateEntityManager(); diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java index c28711c932..d21e7f870c 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java @@ -412,7 +412,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { @SkipForDialects( value = { @SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), - @SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint") + @SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), + @SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY") } ) public void testNativeQueryNullPositionalParameterParameter() throws Exception { @@ -505,7 +506,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { @SkipForDialects( value = { @SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), - @SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint") + @SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), + @SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY") } ) public void testNativeQueryNullNamedParameterParameter() throws Exception { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java index a7c716db3a..1e1651389b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java @@ -6,6 +6,14 @@ */ package org.hibernate.test.annotations.indexcoll; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; @@ -14,20 +22,13 @@ import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.TeradataDialect; import org.hibernate.mapping.Collection; import org.hibernate.mapping.Column; + import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.junit.Test; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -496,7 +497,7 @@ public class IndexedCollectionTest extends BaseNonConfigCoreFunctionalTestCase { assertEquals( 1, atm.colorPerDate.size() ); final Date date = atm.colorPerDate.keySet().iterator().next(); final long diff = new Date( 1234567000 ).getTime() - date.getTime(); - assertTrue( "24h diff max", diff > 0 && diff < 24*60*60*1000 ); + assertTrue( "24h diff max", diff >= 0 && diff < 24*60*60*1000 ); tx.rollback(); s.close(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/eager/EagerIndexedCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/eager/EagerIndexedCollectionTest.java index 012ed726a1..f7f7032d68 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/eager/EagerIndexedCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/eager/EagerIndexedCollectionTest.java @@ -97,7 +97,7 @@ public class EagerIndexedCollectionTest extends BaseNonConfigCoreFunctionalTestC assertEquals( 1, atm.colorPerDate.size() ); final Date date = atm.colorPerDate.keySet().iterator().next(); final long diff = new Date( 1234567000 ).getTime() - date.getTime(); - assertTrue( "24h diff max", diff > 0 && diff < 24*60*60*1000 ); + assertTrue( "24h diff max", diff >= 0 && diff < 24*60*60*1000 ); tx.rollback(); s.close(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java b/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java index 9c74da89c5..08e9cb166b 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java @@ -20,9 +20,15 @@ import java.util.List; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.dialect.Oracle8iDialect; +import org.hibernate.dialect.PostgreSQL9Dialect; +import org.hibernate.dialect.PostgresPlusDialect; import org.hibernate.engine.query.spi.HQLQueryPlan; import org.hibernate.exception.SQLGrammarException; import org.hibernate.hql.spi.QueryTranslator; + +import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -59,6 +65,7 @@ public class CompositeIdTest extends BaseCoreFunctionalTestCase { } @Test + @SkipForDialect(value = Oracle8iDialect.class, comment = "Cannot count distinct over multiple columns in Oracle") public void testDistinctCountOfEntityWithCompositeId() { // today we do not account for Dialects supportsTupleDistinctCounts() is false. though really the only // "option" there is to throw an error. diff --git a/hibernate-core/src/test/java/org/hibernate/test/converter/map/MapKeyAttributeConverterTest.java b/hibernate-core/src/test/java/org/hibernate/test/converter/map/MapKeyAttributeConverterTest.java index c091f29406..d23a369909 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/converter/map/MapKeyAttributeConverterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/converter/map/MapKeyAttributeConverterTest.java @@ -93,7 +93,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes MapValue foundValue = found.enumDefaultType.get( EnumMapKey.VALUE_1 ); assertEquals( EnumMapKey.VALUE_1, foundValue.enumDefault ); - assertEquals( 0, findDatabaseValue( foundValue, "enumDefault" ) ); + assertEquals( 0, ((Number) findDatabaseValue( foundValue, "enumDefault" )).intValue() ); getSession().close(); } @@ -109,7 +109,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes MapValue foundValue = found.enumExplicitOrdinalType.get( EnumMapKey.VALUE_2 ); assertEquals( EnumMapKey.VALUE_2, foundValue.enumExplicitOrdinal ); - assertEquals( 1, findDatabaseValue( foundValue, "enumExplicitOrdinal" ) ); + assertEquals( 1, ((Number) findDatabaseValue( foundValue, "enumExplicitOrdinal" )).intValue() ); getSession().close(); } @@ -173,7 +173,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes MapValue foundValue = found.enumImplicitOverrideOrdinalType.get( ImplicitEnumMapKey.VALUE_1 ); assertEquals( ImplicitEnumMapKey.VALUE_1, foundValue.enumImplicitOverrideOrdinal ); - assertEquals( 0, findDatabaseValue( foundValue, "enumImplicitOverrideOrdinal" ) ); + assertEquals( 0, ((Number) findDatabaseValue( foundValue, "enumImplicitOverrideOrdinal" )).intValue() ); getSession().close(); } @@ -238,7 +238,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes @Table(name = "map_entity") public static class MapEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; @OneToMany(mappedBy = "mapEntity", cascade = CascadeType.ALL) @@ -280,7 +280,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes @Table(name = "map_value") public static class MapValue { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; @ManyToOne @JoinColumn(name = "map_entity_id") diff --git a/hibernate-core/src/test/java/org/hibernate/test/foreignkeys/disabled/InheritanceManyToManyForeignKeyTest.java b/hibernate-core/src/test/java/org/hibernate/test/foreignkeys/disabled/InheritanceManyToManyForeignKeyTest.java index 930ca7f050..7da4197f58 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/foreignkeys/disabled/InheritanceManyToManyForeignKeyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/foreignkeys/disabled/InheritanceManyToManyForeignKeyTest.java @@ -85,7 +85,7 @@ public class InheritanceManyToManyForeignKeyTest extends BaseNonConfigCoreFuncti session.close(); } - @Entity(name = "LocalDateEvent") + @Entity(name = "LDE") public static class LocalDateEvent { @Id @@ -107,7 +107,7 @@ public class InheritanceManyToManyForeignKeyTest extends BaseNonConfigCoreFuncti } } - @Entity(name = "UserEvents") + @Entity(name = "UE") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public static class UserEvents extends AbstractEventsEntityModel { @@ -117,7 +117,7 @@ public class InheritanceManyToManyForeignKeyTest extends BaseNonConfigCoreFuncti } - @Entity(name = "ApplicationEvents") + @Entity(name = "AE") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public static class ApplicationEvents extends AbstractEventsEntityModel { diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java index de44da7524..14c2c69dda 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java @@ -14,6 +14,7 @@ import javax.persistence.PersistenceException; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Projections; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.exception.SQLGrammarException; import org.hibernate.hql.internal.ast.QueryTranslatorImpl; import org.hibernate.hql.internal.ast.tree.SelectClause; @@ -25,6 +26,7 @@ import org.hibernate.type.BigIntegerType; import org.hibernate.type.DoubleType; import org.hibernate.type.LongType; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.junit.After; import org.junit.Before; @@ -206,6 +208,7 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase { } @Test + @SkipForDialect(value = Oracle8iDialect.class, comment = "Cannot count distinct over multiple columns in Oracle") public void testCountReturnValues() { Session s = openSession(); Transaction t = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/id/uuid/interpretation/UUIDBasedIdInterpretationTest.java b/hibernate-core/src/test/java/org/hibernate/test/id/uuid/interpretation/UUIDBasedIdInterpretationTest.java index aef182e4f7..04949a332a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/id/uuid/interpretation/UUIDBasedIdInterpretationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/id/uuid/interpretation/UUIDBasedIdInterpretationTest.java @@ -22,7 +22,6 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.MySQL5Dialect; -import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.mapping.PersistentClass; import org.hibernate.tool.schema.Action; @@ -30,7 +29,7 @@ import org.hibernate.type.PostgresUUIDType; import org.hibernate.type.Type; import org.hibernate.type.UUIDBinaryType; -import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; @@ -103,7 +102,7 @@ public class UUIDBasedIdInterpretationTest extends BaseUnitTestCase { @Test @TestForIssue( jiraKey = "HHH-10564") - @SkipForDialect(PostgreSQL81Dialect.class) + @RequiresDialect(H2Dialect.class) public void testBinaryRuntimeUsage() { StandardServiceRegistry ssr = buildStandardServiceRegistry( H2Dialect.class, true ); try { diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java index c38b25d392..43a555c995 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java @@ -93,9 +93,12 @@ public class SchemaExportTest extends BaseUnitTestCase { // drop beforeQuery create again (this time drops the tables beforeQuery re-creating) schemaExport.execute( EnumSet.of( TargetType.DATABASE ), SchemaExport.Action.BOTH, metadata ); - assertEquals( 0, schemaExport.getExceptions().size() ); + int exceptionCount = schemaExport.getExceptions().size(); + if ( doesDialectSupportDropTableIfExist() ) { + assertEquals( 0, exceptionCount); + } - // drop tables + // drop tables schemaExport.execute( EnumSet.of( TargetType.DATABASE ), SchemaExport.Action.DROP, metadata ); assertEquals( 0, schemaExport.getExceptions().size() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateFormatterTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateFormatterTest.java index 44c80607b5..e8a3bd3ff5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateFormatterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateFormatterTest.java @@ -19,16 +19,17 @@ import org.hibernate.tool.schema.TargetType; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Assert; import org.junit.Test; /** * @author Koen Aers */ +@RequiresDialect(H2Dialect.class) @TestForIssue(jiraKey = "HHH-10158") -@RequiresDialect( H2Dialect.class ) -public class SchemaUpdateFormatterTest { - +public class SchemaUpdateFormatterTest extends BaseUnitTestCase { + private static final String AFTER_FORMAT = "\n\\s+create table test_entity \\(\n" + "\\s+field varchar\\(255\\) not null,\n" + diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java index 8932824e17..68638d268c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java @@ -39,6 +39,8 @@ import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.SourceDescriptor; +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.test.tool.schema.TargetDatabaseImpl; @@ -52,7 +54,7 @@ import static org.junit.Assert.assertThat; /** * @author Andrea Boriero */ - +@RequiresDialectFeature( value = DialectChecks.SupportSchemaCreation.class) public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase { private File output; private StandardServiceRegistry ssr; diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/inheritance/hhh_x/InheritanceSchemaUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/inheritance/hhh_x/InheritanceSchemaUpdateTest.java index c9dfb286d7..c4852f6944 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/inheritance/hhh_x/InheritanceSchemaUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/inheritance/hhh_x/InheritanceSchemaUpdateTest.java @@ -16,12 +16,16 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import org.hibernate.tool.schema.TargetType; +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; +import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; /** * @author Andrea Boriero */ -public class InheritanceSchemaUpdateTest { +@RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class) +public class InheritanceSchemaUpdateTest extends BaseUnitTestCase { @Test public void testBidirectionalOneToManyReferencingRootEntity() throws Exception { diff --git a/hibernate-core/src/test/java/org/hibernate/test/sql/check/ResultCheckStyleTest.java b/hibernate-core/src/test/java/org/hibernate/test/sql/check/ResultCheckStyleTest.java index e82ab1a110..520d1571a2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/sql/check/ResultCheckStyleTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/sql/check/ResultCheckStyleTest.java @@ -6,12 +6,10 @@ */ package org.hibernate.test.sql.check; -import org.junit.Test; - -import org.hibernate.HibernateException; -import org.hibernate.JDBCException; import org.hibernate.Session; + import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; import static org.junit.Assert.fail; @@ -35,11 +33,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( JDBCException ex ) { + catch( Exception ex ) { // these should specifically be JDBCExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } @@ -54,11 +52,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( HibernateException ex ) { + catch( Exception ex ) { // these should specifically be HibernateExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } @@ -74,11 +72,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( JDBCException ex ) { + catch( Exception ex ) { // these should specifically be JDBCExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } @@ -94,11 +92,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( HibernateException ex ) { + catch( Exception ex ) { // these should specifically be HibernateExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } @@ -114,11 +112,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( JDBCException ex ) { + catch( Exception ex ) { // these should specifically be JDBCExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } @@ -134,11 +132,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase { s.flush(); fail( "expection flush failure!" ); } - catch( HibernateException ex ) { + catch( Exception ex ) { // these should specifically be HibernateExceptions... } s.clear(); - s.getTransaction().commit(); + s.getTransaction().rollback(); s.close(); } } diff --git a/hibernate-core/src/test/resources/hibernate.properties b/hibernate-core/src/test/resources/hibernate.properties index b67f40359d..de12583ef4 100644 --- a/hibernate-core/src/test/resources/hibernate.properties +++ b/hibernate-core/src/test/resources/hibernate.properties @@ -23,4 +23,5 @@ hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFa javax.persistence.validation.mode=NONE hibernate.service.allow_crawling=false -hibernate.session.events.log=true \ No newline at end of file +hibernate.session.events.log=true +hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true \ No newline at end of file diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/entities/Address.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/entities/Address.java index d3f8e1d590..6cb51d62c7 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/entities/Address.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/entities/Address.java @@ -6,6 +6,7 @@ */ package org.hibernate.envers.test.integration.query.entities; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @@ -21,6 +22,8 @@ public class Address { private Long id; private String street; + + @Column(name = "`number`") private int number; public Address() { 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 24a96d6ca7..616cea4206 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java @@ -189,4 +189,10 @@ abstract public class DialectChecks { return dialect.supportsRowValueConstructorSyntax() == false; } } + + public static class DoesNotSupportFollowOnLocking implements DialectCheck { + public boolean isMatch(Dialect dialect) { + return !dialect.useFollowOnLocking(); + } + } }