From 8df655aa6b2bbaa4d0766f194de638b5fdcf9a89 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Wed, 21 Nov 2012 12:53:13 -0500 Subject: [PATCH] HHH-7819 Correct test issues found in CI hibernate-core-master-matrix job --- .../test/annotations/enumerated/mapkey/User.java | 3 +++ .../hibernate/test/criterion/CriterionTest.java | 6 +++++- .../org/hibernate/test/hqlfetchscroll/Child.java | 11 +++++++++++ .../test/hqlfetchscroll/HQLScrollFetchTest.java | 2 +- .../hibernate/test/hqlfetchscroll/Parent.java | 13 ++++++++++++- .../test/hqlfetchscroll/ParentChild.hbm.xml | 16 ++++++++++++++-- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/mapkey/User.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/mapkey/User.java index a286af8c18..f0ff936685 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/mapkey/User.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/mapkey/User.java @@ -30,6 +30,8 @@ import javax.persistence.FetchType; import javax.persistence.MapKeyColumn; import javax.persistence.MapKeyEnumerated; import javax.persistence.OneToMany; +import javax.persistence.Table; + import java.util.EnumMap; import java.util.Map; @@ -38,6 +40,7 @@ import java.util.Map; * @author Steve Ebersole */ @Entity +@Table( name = "USER_TABLE" ) public class User { @javax.persistence.Id @javax.persistence.GeneratedValue(generator = "system-uuid") diff --git a/hibernate-core/src/test/java/org/hibernate/test/criterion/CriterionTest.java b/hibernate-core/src/test/java/org/hibernate/test/criterion/CriterionTest.java index f95cca09aa..f501c81062 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/criterion/CriterionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criterion/CriterionTest.java @@ -29,6 +29,7 @@ import org.hibernate.IrrelevantEntity; import org.hibernate.SessionFactory; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; import org.hibernate.criterion.CriteriaQuery; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.LikeExpression; @@ -42,6 +43,7 @@ import org.hibernate.type.Type; import org.junit.Test; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertEquals; @@ -49,12 +51,13 @@ import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ -public class CriterionTest extends BaseUnitTestCase { +public class CriterionTest extends BaseCoreFunctionalTestCase { @Test public void testIlikeRendering() { SessionFactory sf = new Configuration() .addAnnotatedClass( IrrelevantEntity.class ) .setProperty( AvailableSettings.DIALECT, IlikeSupportingDialect.class.getName() ) + .setProperty( Environment.HBM2DDL_AUTO, "create-drop" ) .buildSessionFactory(); final Criteria criteria = sf.openSession().createCriteria( IrrelevantEntity.class ); final CriteriaQueryTranslator translator = new CriteriaQueryTranslator( @@ -73,6 +76,7 @@ public class CriterionTest extends BaseUnitTestCase { SessionFactory sf = new Configuration() .addAnnotatedClass( IrrelevantEntity.class ) .setProperty( AvailableSettings.DIALECT, NonIlikeSupportingDialect.class.getName() ) + .setProperty( Environment.HBM2DDL_AUTO, "create-drop" ) .buildSessionFactory(); final Criteria criteria = sf.openSession().createCriteria( IrrelevantEntity.class ); final CriteriaQueryTranslator translator = new CriteriaQueryTranslator( diff --git a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Child.java b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Child.java index dfd7072816..54f6a9791d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Child.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Child.java @@ -2,6 +2,9 @@ package org.hibernate.test.hqlfetchscroll; public class Child { + // A numeric id must be the field. Some databases (Sybase, etc.) + // require identifier columns in order to support scrollable results. + private long id; private String name; Child() { @@ -11,6 +14,14 @@ public class Child { this.name = name; } + public long getId() { + return id; + } + + void setId(long id) { + this.id = id; + } + public String getName() { return name; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/HQLScrollFetchTest.java b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/HQLScrollFetchTest.java index 5b373219ad..ab2a026a42 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/HQLScrollFetchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/HQLScrollFetchTest.java @@ -176,8 +176,8 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase { } } // check that the same second parent is obtained by calling Session.get() - assertSame( pOther, s.get( Parent.class, "parent2" ) ); assertNotNull( pOther ); + assertSame( pOther, s.get( Parent.class, pOther.getId() ) ); // access pOther's collection; should be completely loaded assertTrue( Hibernate.isInitialized( pOther.getChildren() ) ); assertEquals( childrenOther, pOther.getChildren() ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Parent.java b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Parent.java index 253b53cd4e..1ce74e3c5d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Parent.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/Parent.java @@ -4,6 +4,10 @@ import java.util.HashSet; import java.util.Set; public class Parent { + + // A numeric id must be the field. Some databases (Sybase, etc.) + // require identifier columns in order to support scrollable results. + private long id; private String name; private Set children = new HashSet(); @@ -14,11 +18,18 @@ public class Parent { this.name = name; } + public long getId() { + return id; + } + + void setId(long id) { + this.id = id; + } + public String getName() { return name; } - void setName(String name) { this.name = name; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/ParentChild.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/ParentChild.hbm.xml index 266c5b930a..3eda47a0ad 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/ParentChild.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/test/hqlfetchscroll/ParentChild.hbm.xml @@ -6,7 +6,13 @@ - + + + + + + @@ -16,7 +22,13 @@ - + + + + + +