HHH-14234 fix CI building error on non-H2 dialect

This commit is contained in:
Nathan Xu 2020-10-19 09:08:57 -04:00 committed by Christian Beikov
parent f8fb0b0069
commit f17c0f7a03
1 changed files with 10 additions and 4 deletions

View File

@ -12,7 +12,9 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect;
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;
@ -22,6 +24,11 @@ import org.junit.Test;
* @author Nathan Xu * @author Nathan Xu
*/ */
@TestForIssue( jiraKey = "HHH-14234" ) @TestForIssue( jiraKey = "HHH-14234" )
@RequiresDialect(
value = H2Dialect.class,
comment = "This test relies on 'hibernate.hbm2ddl.halt_on_error', only tested on h2; " +
"other dialects might be broken due to irrelevant reason (e.g. not supporting 'if exists' while dropping tables)."
)
public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNonConfigCoreFunctionalTestCase { public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNonConfigCoreFunctionalTestCase {
@Override @Override
@ -40,13 +47,12 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo
@Test @Test
public void testUniqueConstraintFromSupTableNotAppliedToSubTable() { public void testUniqueConstraintFromSupTableNotAppliedToSubTable() {
// Unique constraint should be unique in db // Unique constraint should be unique in db
// Without fixing, exception will be thrown when unique constraint in 'SUPTABLE' is applied to 'SUBTABLE' as well // Without fixing, exception will be thrown when unique constraint in 'supTable' is applied to 'subTable' as well
// Both table names are uppercase to accommodate HANA dialect (see https://stackoverflow.com/questions/29974507/sap-hana-invalid-table-name)
} }
@Entity(name = "SuperClass") @Entity(name = "SuperClass")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table( name = "SUPTABLE", @Table( name = "supTable",
uniqueConstraints = { uniqueConstraints = {
@UniqueConstraint( name = "UK", @UniqueConstraint( name = "UK",
columnNames = {"colOne", "colTwo"}) columnNames = {"colOne", "colTwo"})
@ -66,7 +72,7 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo
} }
@Entity(name = "SubClass") @Entity(name = "SubClass")
@Table( name = "SUBTABLE" ) @Table( name = "subTable" )
static class SubClass extends SuperClass { static class SubClass extends SuperClass {
@Column(name = "colThree") @Column(name = "colThree")