HHH-6836 some test failures on Oracle

This commit is contained in:
Strong Liu 2011-11-21 19:53:09 +08:00
parent b2ba384254
commit c4776e2a92
8 changed files with 83 additions and 51 deletions

View File

@ -31,6 +31,7 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.SQLServer2005Dialect;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.SkipForDialect;
@ -153,7 +154,8 @@ public class ManyToOneWithFormulaTest extends BaseCoreFunctionalTestCase {
}
@Test
@SkipForDialect(value = { HSQLDialect.class, SQLServer2005Dialect.class }, comment = "The used join conditions does not work in HSQLDB. See HHH-4497")
@SkipForDialect(value = { HSQLDialect.class, SQLServer2005Dialect.class, Oracle8iDialect.class },
comment = "The used join conditions does not work in HSQLDB. See HHH-4497. And oracle does not support 'substring' function, it uses 'substr'")
public void testManyToOneFromNonPkToNonPk() throws Exception {
// also tests usage of the stand-alone @JoinFormula annotation (i.e. not wrapped within @JoinColumnsOrFormulas)
Session s = openSession();

View File

@ -0,0 +1,8 @@
package org.hibernate.test.criteria;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public enum Code {
ADM, CEN, RPA, RPP, PRJ, HUB, RQS, OAD, ORP, ORQ
}

View File

@ -25,15 +25,6 @@
package org.hibernate.test.criteria;
import java.util.Arrays;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import org.junit.Test;
@ -104,45 +95,6 @@ import static org.junit.Assert.assertEquals;
*/
public class ComplexJoinAliasTest extends BaseCoreFunctionalTestCase {
@MappedSuperclass
private static abstract class VersionedRecord implements java.io.Serializable {
Long recordVersion;
Boolean isDeleted;
}
@Entity
@IdClass(ListActionRole.class)
public static class ListActionRole extends VersionedRecord {
@Id
@Enumerated(EnumType.STRING)
Code roleCode;
@ManyToOne(targetEntity = Role.class)
@JoinColumn(nullable = false)
Role role;
@Override
public String toString() {
return "ListActionRole.Id(roleCode=" + roleCode + ")";
}
@Override
public int hashCode() {
return toString().hashCode();
}
}
@Entity
@Table(name = "roles")
public static class Role extends VersionedRecord {
@Id
@Enumerated(EnumType.STRING)
Code code;
}
public static enum Code {
ADM, CEN, RPA, RPP, PRJ, HUB, RQS, OAD, ORP, ORQ
}
@Override
protected Class<?>[] getAnnotatedClasses() {

View File

@ -0,0 +1,34 @@
package org.hibernate.test.criteria;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
@Entity
@IdClass(ListActionRole.class)
public class ListActionRole extends VersionedRecord {
@Id
@Enumerated(EnumType.STRING)
Code roleCode;
@ManyToOne(targetEntity = Role.class)
@JoinColumn(nullable = false)
Role role;
@Override
public String toString() {
return "ListActionRole.Id(roleCode=" + roleCode + ")";
}
@Override
public int hashCode() {
return toString().hashCode();
}
}

View File

@ -0,0 +1,18 @@
package org.hibernate.test.criteria;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
@Entity
@Table(name = "roles")
public class Role extends VersionedRecord {
@Id
@Enumerated(EnumType.STRING)
Code code;
}

View File

@ -0,0 +1,12 @@
package org.hibernate.test.criteria;
import javax.persistence.MappedSuperclass;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
@MappedSuperclass
abstract class VersionedRecord implements java.io.Serializable {
Long recordVersion;
Boolean isDeleted;
}

View File

@ -27,6 +27,7 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -38,7 +39,12 @@ import static org.junit.Assert.assertNotNull;
@RequiresDialect( Oracle9iDialect.class )
public class SequenceIdentityTest extends BaseCoreFunctionalTestCase {
public void configure(Configuration cfg) {
super.configure( cfg );
//this test makes no sense w/o the following property enabled
//note : this property is set to false by default in Oracle9iDialect
//but if this property is set to false, then the AssertionFailure will
//be thrown by {@link org.hibernate.engine.jdbc.internal.StatementPreparerImpl.checkAutoGeneratedKeysSupportEnabled()}
//so let just change this here and this should be invested deeper.
cfg.setProperty( Environment.USE_GET_GENERATED_KEYS, "true" );
}
public String[] getMappings() {

View File

@ -47,7 +47,7 @@
</id>
<property name="description" type="string"/>
<many-to-one name="user" column="`user`"/>
<many-to-one name="resource"/>
<many-to-one name="resource" column="`resource`"/>
<property name="dueDate" type="timestamp"/>
<property name="startDate" type="timestamp"/>
<property name="completionDate" type="timestamp"/>