HHH-10689 - Fix tests failing when switching to Oracle

This commit is contained in:
Vlad Mihalcea 2016-04-26 12:55:05 +03:00 committed by Vlad Mihalcea
parent eb2bf6e2e7
commit 231484662b
27 changed files with 152 additions and 67 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
/build /build
*/build */build
testdb testdb
lib
# IntelliJ specific files/directories # IntelliJ specific files/directories
out out

View File

@ -149,6 +149,18 @@ subprojects { subProject ->
testRuntime( libraries.mariadb ) testRuntime( libraries.mariadb )
testRuntime( libraries.woodstox ) 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... // 6.6 gave me some NPE problems from within checkstyle...
checkstyle 'com.puppycrawl.tools:checkstyle:6.5' checkstyle 'com.puppycrawl.tools:checkstyle:6.5'
} }

View File

@ -73,6 +73,19 @@ dependencies {
testRuntime( libraries.hsqldb ) testRuntime( libraries.hsqldb )
testRuntime( libraries.postgresql ) testRuntime( libraries.postgresql )
testRuntime( libraries.mysql ) testRuntime( libraries.mysql )
testRuntime( libraries.mariadb )
if (db.equalsIgnoreCase("oracle")) {
dependencies {
testRuntime( libraries.oracle )
}
}
if (db.equalsIgnoreCase("mssql")) {
dependencies {
testRuntime( libraries.mssql )
}
}
} }
processTestResources.doLast( { processTestResources.doLast( {

View File

@ -14,7 +14,7 @@ import org.hibernate.testing.RequiresDialect;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RequiresDialect( value = H2Dialect.class) @RequiresDialect(H2Dialect.class)
public class DatabaseMultiTenancyTest extends AbstractMultiTenancyTest { public class DatabaseMultiTenancyTest extends AbstractMultiTenancyTest {
@Override @Override

View File

@ -14,7 +14,7 @@ import org.hibernate.testing.RequiresDialect;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RequiresDialect( value = H2Dialect.class) @RequiresDialect(H2Dialect.class)
public class SchemaMultiTenancyTest extends AbstractMultiTenancyTest { public class SchemaMultiTenancyTest extends AbstractMultiTenancyTest {
public static final String SCHEMA_TOKEN = ";INIT=CREATE SCHEMA IF NOT EXISTS %1$s\\;SET SCHEMA %1$s"; public static final String SCHEMA_TOKEN = ";INIT=CREATE SCHEMA IF NOT EXISTS %1$s\\;SET SCHEMA %1$s";

View File

@ -7,6 +7,7 @@
package org.hibernate.userguide.sql; package org.hibernate.userguide.sql;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.ElementCollection; import javax.persistence.ElementCollection;
@ -23,8 +24,12 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate; import org.hibernate.annotations.SQLUpdate;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialects;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -39,6 +44,7 @@ import static org.junit.Assert.assertEquals;
* *
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)})
public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase { public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( CollectionLoaderTest.class ); 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 session = entityManager.unwrap( Session.class );
session.doWork( connection -> { session.doWork( connection -> {
try(Statement statement = connection.createStatement(); ) { try(Statement statement = connection.createStatement(); ) {
statement.executeUpdate( "ALTER TABLE person ADD COLUMN valid boolean" ); statement.executeUpdate( String.format( "ALTER TABLE person %s valid %s",
statement.executeUpdate( "ALTER TABLE Person_phones ADD COLUMN valid boolean" ); getDialect().getAddColumnString(), getDialect().getTypeName( Types.BOOLEAN )));
statement.executeUpdate( String.format( "ALTER TABLE Person_phones %s valid %s",
getDialect().getAddColumnString(), getDialect().getTypeName( Types.BOOLEAN )));
} }
} ); } );
}); });

View File

@ -22,8 +22,12 @@ import org.hibernate.annotations.Loader;
import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.ResultCheckStyle;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLInsert;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialects;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -36,6 +40,7 @@ import static org.junit.Assert.assertNull;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)})
public class CustomSQLSecondaryTableTest extends BaseEntityManagerFunctionalTestCase { public class CustomSQLSecondaryTableTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( CustomSQLSecondaryTableTest.class ); private static final Logger log = Logger.getLogger( CustomSQLSecondaryTableTest.class );

View File

@ -24,8 +24,12 @@ import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate; import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialects;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -38,6 +42,7 @@ import static org.junit.Assert.assertNull;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@RequiresDialects(value = {@RequiresDialect(H2Dialect.class), @RequiresDialect(PostgreSQL82Dialect.class)})
public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase { public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( CustomSQLTest.class ); private static final Logger log = Logger.getLogger( CustomSQLTest.class );

View File

@ -164,8 +164,6 @@ xjc {
//sourceSets.main.sourceGeneratorsTask.dependsOn generateGrammarSource //sourceSets.main.sourceGeneratorsTask.dependsOn generateGrammarSource
tasks.compile.dependsOn generateGrammarSource tasks.compile.dependsOn generateGrammarSource
task copyBundleResources (type: Copy) { task copyBundleResources (type: Copy) {
ext.bundlesTargetDir = file( "${buildDir}/bundles" ) ext.bundlesTargetDir = file( "${buildDir}/bundles" )
from file('src/test/bundles') from file('src/test/bundles')

View File

@ -21,6 +21,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Test; import org.junit.Test;
@ -31,7 +32,8 @@ import static org.junit.Assert.assertEquals;
* @author Janario Oliveira * @author Janario Oliveira
* @author Gail Badner * @author Gail Badner
*/ */
public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalTestCase { public class EntitySuperclassCollectionTest
extends BaseEntityManagerFunctionalTestCase {
@Override @Override
protected Class<?>[] getAnnotatedClasses() { protected Class<?>[] getAnnotatedClasses() {
return new Class[] { return new Class[] {
@ -40,7 +42,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT
} }
@Test @Test
@TestForIssue( jiraKey = "HHH-10556") @TestForIssue(jiraKey = "HHH-10556")
public void testPerson() { public void testPerson() {
String address = "super-address"; String address = "super-address";
@ -50,10 +52,17 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT
} }
private void assertAddress(PersonBase person, String address) { private void assertAddress(PersonBase person, String address) {
List<Object> results = find( person.getClass(), person.id, "addresses" ); List<Object> results = find(
person.getClass(),
person.id,
"addresses"
);
assertEquals( 1, results.size() ); 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 ); assertEquals( address, ( (Address) results.get( 0 ) ).name );
getOrCreateEntityManager().close(); getOrCreateEntityManager().close();
@ -83,7 +92,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT
return query.getResultList(); return query.getResultList();
} }
@Entity(name="Address") @Entity(name = "Address")
public static class Address { public static class Address {
@Id @Id
@GeneratedValue @GeneratedValue
@ -98,7 +107,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT
} }
} }
@Entity @Entity(name = "PersonBase")
public abstract static class PersonBase { public abstract static class PersonBase {
@Id @Id
@GeneratedValue @GeneratedValue
@ -107,7 +116,7 @@ public class EntitySuperclassCollectionTest extends BaseEntityManagerFunctionalT
List<Address> addresses = new ArrayList<Address>(); List<Address> addresses = new ArrayList<Address>();
} }
@Entity(name="Person") @Entity(name = "Person")
public static class Person extends PersonBase { public static class Person extends PersonBase {
} }
} }

View File

@ -6,8 +6,16 @@
*/ */
package org.hibernate.jpa.test.lock; 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.List;
import java.util.Map; import java.util.Map;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Id; import javax.persistence.Id;
@ -22,16 +30,11 @@ import org.hibernate.jpa.QueryHints;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.query.NativeQuery; import org.hibernate.query.NativeQuery;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Test; 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 * @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 * lock some entities via a query and check the resulting lock mode type via EntityManager
*/ */
@Test @Test
@RequiresDialectFeature( value = DialectChecks.DoesNotSupportFollowOnLocking.class)
public void testEntityLockModeStateAfterQueryLocking() { public void testEntityLockModeStateAfterQueryLocking() {
// Create some test data // Create some test data
EntityManager em = getOrCreateEntityManager(); EntityManager em = getOrCreateEntityManager();

View File

@ -412,7 +412,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
@SkipForDialects( @SkipForDialects(
value = { value = {
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), @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 { public void testNativeQueryNullPositionalParameterParameter() throws Exception {
@ -505,7 +506,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
@SkipForDialects( @SkipForDialects(
value = { value = {
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint"), @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 { public void testNativeQueryNullNamedParameterParameter() throws Exception {

View File

@ -6,6 +6,14 @@
*/ */
package org.hibernate.test.annotations.indexcoll; 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.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -14,20 +22,13 @@ import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.TeradataDialect; import org.hibernate.dialect.TeradataDialect;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.Test; 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.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -496,7 +497,7 @@ public class IndexedCollectionTest extends BaseNonConfigCoreFunctionalTestCase {
assertEquals( 1, atm.colorPerDate.size() ); assertEquals( 1, atm.colorPerDate.size() );
final Date date = atm.colorPerDate.keySet().iterator().next(); final Date date = atm.colorPerDate.keySet().iterator().next();
final long diff = new Date( 1234567000 ).getTime() - date.getTime(); 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(); tx.rollback();
s.close(); s.close();
} }

View File

@ -97,7 +97,7 @@ public class EagerIndexedCollectionTest extends BaseNonConfigCoreFunctionalTestC
assertEquals( 1, atm.colorPerDate.size() ); assertEquals( 1, atm.colorPerDate.size() );
final Date date = atm.colorPerDate.keySet().iterator().next(); final Date date = atm.colorPerDate.keySet().iterator().next();
final long diff = new Date( 1234567000 ).getTime() - date.getTime(); 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(); tx.rollback();
s.close(); s.close();
} }

View File

@ -20,9 +20,15 @@ import java.util.List;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; 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.engine.query.spi.HQLQueryPlan;
import org.hibernate.exception.SQLGrammarException; import org.hibernate.exception.SQLGrammarException;
import org.hibernate.hql.spi.QueryTranslator; import org.hibernate.hql.spi.QueryTranslator;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipForDialects;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -59,6 +65,7 @@ public class CompositeIdTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = Oracle8iDialect.class, comment = "Cannot count distinct over multiple columns in Oracle")
public void testDistinctCountOfEntityWithCompositeId() { public void testDistinctCountOfEntityWithCompositeId() {
// today we do not account for Dialects supportsTupleDistinctCounts() is false. though really the only // today we do not account for Dialects supportsTupleDistinctCounts() is false. though really the only
// "option" there is to throw an error. // "option" there is to throw an error.

View File

@ -93,7 +93,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
MapValue foundValue = found.enumDefaultType.get( EnumMapKey.VALUE_1 ); MapValue foundValue = found.enumDefaultType.get( EnumMapKey.VALUE_1 );
assertEquals( EnumMapKey.VALUE_1, foundValue.enumDefault ); assertEquals( EnumMapKey.VALUE_1, foundValue.enumDefault );
assertEquals( 0, findDatabaseValue( foundValue, "enumDefault" ) ); assertEquals( 0, ((Number) findDatabaseValue( foundValue, "enumDefault" )).intValue() );
getSession().close(); getSession().close();
} }
@ -109,7 +109,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
MapValue foundValue = found.enumExplicitOrdinalType.get( EnumMapKey.VALUE_2 ); MapValue foundValue = found.enumExplicitOrdinalType.get( EnumMapKey.VALUE_2 );
assertEquals( EnumMapKey.VALUE_2, foundValue.enumExplicitOrdinal ); assertEquals( EnumMapKey.VALUE_2, foundValue.enumExplicitOrdinal );
assertEquals( 1, findDatabaseValue( foundValue, "enumExplicitOrdinal" ) ); assertEquals( 1, ((Number) findDatabaseValue( foundValue, "enumExplicitOrdinal" )).intValue() );
getSession().close(); getSession().close();
} }
@ -173,7 +173,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
MapValue foundValue = found.enumImplicitOverrideOrdinalType.get( ImplicitEnumMapKey.VALUE_1 ); MapValue foundValue = found.enumImplicitOverrideOrdinalType.get( ImplicitEnumMapKey.VALUE_1 );
assertEquals( ImplicitEnumMapKey.VALUE_1, foundValue.enumImplicitOverrideOrdinal ); assertEquals( ImplicitEnumMapKey.VALUE_1, foundValue.enumImplicitOverrideOrdinal );
assertEquals( 0, findDatabaseValue( foundValue, "enumImplicitOverrideOrdinal" ) ); assertEquals( 0, ((Number) findDatabaseValue( foundValue, "enumImplicitOverrideOrdinal" )).intValue() );
getSession().close(); getSession().close();
} }
@ -238,7 +238,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
@Table(name = "map_entity") @Table(name = "map_entity")
public static class MapEntity { public static class MapEntity {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.AUTO)
private Integer id; private Integer id;
@OneToMany(mappedBy = "mapEntity", cascade = CascadeType.ALL) @OneToMany(mappedBy = "mapEntity", cascade = CascadeType.ALL)
@ -280,7 +280,7 @@ public class MapKeyAttributeConverterTest extends BaseNonConfigCoreFunctionalTes
@Table(name = "map_value") @Table(name = "map_value")
public static class MapValue { public static class MapValue {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.AUTO)
private Integer id; private Integer id;
@ManyToOne @ManyToOne
@JoinColumn(name = "map_entity_id") @JoinColumn(name = "map_entity_id")

View File

@ -85,7 +85,7 @@ public class InheritanceManyToManyForeignKeyTest extends BaseNonConfigCoreFuncti
session.close(); session.close();
} }
@Entity(name = "LocalDateEvent") @Entity(name = "LDE")
public static class LocalDateEvent { public static class LocalDateEvent {
@Id @Id
@ -107,7 +107,7 @@ public class InheritanceManyToManyForeignKeyTest extends BaseNonConfigCoreFuncti
} }
} }
@Entity(name = "UserEvents") @Entity(name = "UE")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public static class UserEvents extends AbstractEventsEntityModel { 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) @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public static class ApplicationEvents extends AbstractEventsEntityModel { public static class ApplicationEvents extends AbstractEventsEntityModel {

View File

@ -14,6 +14,7 @@ import javax.persistence.PersistenceException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.exception.SQLGrammarException; import org.hibernate.exception.SQLGrammarException;
import org.hibernate.hql.internal.ast.QueryTranslatorImpl; import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
import org.hibernate.hql.internal.ast.tree.SelectClause; 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.DoubleType;
import org.hibernate.type.LongType; import org.hibernate.type.LongType;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -206,6 +208,7 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
} }
@Test @Test
@SkipForDialect(value = Oracle8iDialect.class, comment = "Cannot count distinct over multiple columns in Oracle")
public void testCountReturnValues() { public void testCountReturnValues() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -22,7 +22,6 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.tool.schema.Action; import org.hibernate.tool.schema.Action;
@ -30,7 +29,7 @@ import org.hibernate.type.PostgresUUIDType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.UUIDBinaryType; import org.hibernate.type.UUIDBinaryType;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
@ -103,7 +102,7 @@ public class UUIDBasedIdInterpretationTest extends BaseUnitTestCase {
@Test @Test
@TestForIssue( jiraKey = "HHH-10564") @TestForIssue( jiraKey = "HHH-10564")
@SkipForDialect(PostgreSQL81Dialect.class) @RequiresDialect(H2Dialect.class)
public void testBinaryRuntimeUsage() { public void testBinaryRuntimeUsage() {
StandardServiceRegistry ssr = buildStandardServiceRegistry( H2Dialect.class, true ); StandardServiceRegistry ssr = buildStandardServiceRegistry( H2Dialect.class, true );
try { try {

View File

@ -93,9 +93,12 @@ public class SchemaExportTest extends BaseUnitTestCase {
// drop beforeQuery create again (this time drops the tables beforeQuery re-creating) // drop beforeQuery create again (this time drops the tables beforeQuery re-creating)
schemaExport.execute( EnumSet.of( TargetType.DATABASE ), SchemaExport.Action.BOTH, metadata ); 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 ); schemaExport.execute( EnumSet.of( TargetType.DATABASE ), SchemaExport.Action.DROP, metadata );
assertEquals( 0, schemaExport.getExceptions().size() ); assertEquals( 0, schemaExport.getExceptions().size() );
} }

View File

@ -19,16 +19,17 @@ import org.hibernate.tool.schema.TargetType;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* @author Koen Aers * @author Koen Aers
*/ */
@RequiresDialect(H2Dialect.class)
@TestForIssue(jiraKey = "HHH-10158") @TestForIssue(jiraKey = "HHH-10158")
@RequiresDialect( H2Dialect.class ) public class SchemaUpdateFormatterTest extends BaseUnitTestCase {
public class SchemaUpdateFormatterTest {
private static final String AFTER_FORMAT = private static final String AFTER_FORMAT =
"\n\\s+create table test_entity \\(\n" + "\n\\s+create table test_entity \\(\n" +
"\\s+field varchar\\(255\\) not null,\n" + "\\s+field varchar\\(255\\) not null,\n" +

View File

@ -39,6 +39,8 @@ import org.hibernate.tool.schema.spi.SchemaManagementTool;
import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptSourceInput;
import org.hibernate.tool.schema.spi.SourceDescriptor; 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.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.tool.schema.TargetDatabaseImpl; import org.hibernate.test.tool.schema.TargetDatabaseImpl;
@ -52,7 +54,7 @@ import static org.junit.Assert.assertThat;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
*/ */
@RequiresDialectFeature( value = DialectChecks.SupportSchemaCreation.class)
public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase { public class CrossSchemaForeignKeyGenerationTest extends BaseUnitTestCase {
private File output; private File output;
private StandardServiceRegistry ssr; private StandardServiceRegistry ssr;

View File

@ -16,12 +16,16 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate; import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType; 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; import org.junit.Test;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
*/ */
public class InheritanceSchemaUpdateTest { @RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class)
public class InheritanceSchemaUpdateTest extends BaseUnitTestCase {
@Test @Test
public void testBidirectionalOneToManyReferencingRootEntity() throws Exception { public void testBidirectionalOneToManyReferencingRootEntity() throws Exception {

View File

@ -6,12 +6,10 @@
*/ */
package org.hibernate.test.sql.check; 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.Session;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -35,11 +33,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( JDBCException ex ) { catch( Exception ex ) {
// these should specifically be JDBCExceptions... // these should specifically be JDBCExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
@ -54,11 +52,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( HibernateException ex ) { catch( Exception ex ) {
// these should specifically be HibernateExceptions... // these should specifically be HibernateExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
@ -74,11 +72,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( JDBCException ex ) { catch( Exception ex ) {
// these should specifically be JDBCExceptions... // these should specifically be JDBCExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
@ -94,11 +92,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( HibernateException ex ) { catch( Exception ex ) {
// these should specifically be HibernateExceptions... // these should specifically be HibernateExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
@ -114,11 +112,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( JDBCException ex ) { catch( Exception ex ) {
// these should specifically be JDBCExceptions... // these should specifically be JDBCExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
@ -134,11 +132,11 @@ public abstract class ResultCheckStyleTest extends BaseCoreFunctionalTestCase {
s.flush(); s.flush();
fail( "expection flush failure!" ); fail( "expection flush failure!" );
} }
catch( HibernateException ex ) { catch( Exception ex ) {
// these should specifically be HibernateExceptions... // these should specifically be HibernateExceptions...
} }
s.clear(); s.clear();
s.getTransaction().commit(); s.getTransaction().rollback();
s.close(); s.close();
} }
} }

View File

@ -23,4 +23,5 @@ hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFa
javax.persistence.validation.mode=NONE javax.persistence.validation.mode=NONE
hibernate.service.allow_crawling=false hibernate.service.allow_crawling=false
hibernate.session.events.log=true hibernate.session.events.log=true
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.envers.test.integration.query.entities; package org.hibernate.envers.test.integration.query.entities;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -21,6 +22,8 @@ public class Address {
private Long id; private Long id;
private String street; private String street;
@Column(name = "`number`")
private int number; private int number;
public Address() { public Address() {

View File

@ -189,4 +189,10 @@ abstract public class DialectChecks {
return dialect.supportsRowValueConstructorSyntax() == false; return dialect.supportsRowValueConstructorSyntax() == false;
} }
} }
public static class DoesNotSupportFollowOnLocking implements DialectCheck {
public boolean isMatch(Dialect dialect) {
return !dialect.useFollowOnLocking();
}
}
} }