From 3973bf3d53f40e538d6310b6458d5a9bae71eec0 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 17 Dec 2010 16:58:52 -0800 Subject: [PATCH 1/7] HHH-5791 : NPE merging transient entity with non-nullable property set to null with delayed insert if check_nullability set to false --- .../event/def/DefaultMergeEventListener.java | 42 +++++----- ...ascadeCheckNullFalseDelayedInsertTest.java | 52 ++++++++++++ ...CascadeCheckNullTrueDelayedInsertTest.java | 51 ++++++++++++ ...ultiPathCircleCascadeDelayedInsert.hbm.xml | 82 +++++++++++++++++++ ...ltiPathCircleCascadeDelayedInsertTest.java | 65 +++++++++++++++ .../circle/MultiPathCircleCascadeTest.java | 50 +++++++---- 6 files changed, 303 insertions(+), 39 deletions(-) create mode 100644 testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.java create mode 100644 testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.java create mode 100644 testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml create mode 100644 testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsertTest.java diff --git a/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java b/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java index 63767ac45cc7..7b644928899b 100755 --- a/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java +++ b/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java @@ -346,9 +346,19 @@ private Object mergeTransientEntity( Object propertyFromEntity = persister.getPropertyValue( entity, propertyName, source.getEntityMode() ); Type propertyType = persister.getPropertyType( propertyName ); EntityEntry copyEntry = source.getPersistenceContext().getEntry( copy ); - if ( propertyFromCopy == null || ! propertyType.isEntityType() ) { - log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + - "' is null or not an entity; " + propertyName + " =["+propertyFromCopy+"]"); + if ( propertyFromCopy == null || + propertyFromEntity == null || + ! propertyType.isEntityType() || + ! copyCache.containsKey( propertyFromEntity ) ) { + if ( log.isTraceEnabled() ) { + String fullPropertyName = "property '" + copyEntry.getEntityName() + "." + propertyName; + log.trace( fullPropertyName + " in copy is " + ( propertyFromCopy == null ? "null" : propertyFromCopy ) ); + log.trace( fullPropertyName + " in original is " + ( propertyFromCopy == null ? "null" : propertyFromCopy ) ); + log.trace( fullPropertyName + ( propertyType.isEntityType() ? " is" : " is not" ) + " an entity type" ); + if ( propertyFromEntity != null && ! copyCache.containsKey( propertyFromEntity ) ) { + log.trace( fullPropertyName + " is not in copy cache" ); + } + } if ( isNullabilityCheckedGlobal( source ) ) { throw ex; } @@ -358,28 +368,18 @@ private Object mergeTransientEntity( saveTransientEntity( copy, entityName, requestedId, source, copyCache, false ); } } - if ( ! copyCache.containsKey( propertyFromEntity ) ) { - log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + - "' from original entity is not in copyCache; " + propertyName + " =["+propertyFromEntity+"]"); - if ( isNullabilityCheckedGlobal( source ) ) { - throw ex; + if ( log.isTraceEnabled() && propertyFromEntity != null ) { + if ( ( ( EventCache ) copyCache ).isOperatedOn( propertyFromEntity ) ) { + log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + + "' from original entity is in copyCache and is in the process of being merged; " + + propertyName + " =["+propertyFromEntity+"]"); } else { - // retry save w/o checking non-nullable properties - // (the failure will be detected later) - saveTransientEntity( copy, entityName, requestedId, source, copyCache, false ); + log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + + "' from original entity is in copyCache and is not in the process of being merged; " + + propertyName + " =["+propertyFromEntity+"]"); } } - if ( ( ( EventCache ) copyCache ).isOperatedOn( propertyFromEntity ) ) { - log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + - "' from original entity is in copyCache and is in the process of being merged; " + - propertyName + " =["+propertyFromEntity+"]"); - } - else { - log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName + - "' from original entity is in copyCache and is not in the process of being merged; " + - propertyName + " =["+propertyFromEntity+"]"); - } // continue...; we'll find out if it ends up not getting saved later } diff --git a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.java b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.java new file mode 100644 index 000000000000..b9353399bfc1 --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.java @@ -0,0 +1,52 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Middleware LLC. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ +package org.hibernate.test.cascade.circle; + +import junit.framework.Test; + +import org.hibernate.TransientObjectException; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; + +/** + * @author Gail Badner + */ +public class MultiPathCircleCascadeCheckNullFalseDelayedInsertTest extends MultiPathCircleCascadeDelayedInsertTest { + + public MultiPathCircleCascadeCheckNullFalseDelayedInsertTest(String str) { + super( str ); + } + + @Override + public void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.CHECK_NULLABILITY, "false" ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.class ); + } +} \ No newline at end of file diff --git a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.java b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.java new file mode 100644 index 000000000000..750b7c6ccbd6 --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.java @@ -0,0 +1,51 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Middleware LLC. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ +package org.hibernate.test.cascade.circle; + +import junit.framework.Test; + +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; +import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; + +/** + * @author Gail Badner + */ +public class MultiPathCircleCascadeCheckNullTrueDelayedInsertTest extends MultiPathCircleCascadeDelayedInsertTest { + + public MultiPathCircleCascadeCheckNullTrueDelayedInsertTest(String str) { + super( str ); + } + + @Override + public void configure(Configuration cfg) { + super.configure( cfg ); + cfg.setProperty( Environment.CHECK_NULLABILITY, "true" ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.class ); + } +} \ No newline at end of file diff --git a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml new file mode 100644 index 000000000000..985fd92891f3 --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsertTest.java b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsertTest.java new file mode 100644 index 000000000000..d6531a25c0e4 --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeDelayedInsertTest.java @@ -0,0 +1,65 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Middleware LLC. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ +package org.hibernate.test.cascade.circle; + +import junit.framework.Test; + +import org.hibernate.JDBCException; +import org.hibernate.PropertyValueException; +import org.hibernate.TransientObjectException; +import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; + +/** + * @author Gail Badner + */ +public class MultiPathCircleCascadeDelayedInsertTest extends MultiPathCircleCascadeTest { + public MultiPathCircleCascadeDelayedInsertTest(String string) { + super(string); + } + + public String[] getMappings() { + return new String[] { + "cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml" + }; + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( MultiPathCircleCascadeDelayedInsertTest.class ); + } + + protected void checkExceptionFromNullValueForNonNullable(Exception ex, boolean checkNullability, boolean isNullValue ) { + if ( checkNullability ) { + if ( isNullValue ) { + assertTrue( ex instanceof PropertyValueException ); + } + else { + assertTrue( ex instanceof TransientObjectException ); + } + } + else { + assertTrue( ex instanceof JDBCException || ex instanceof TransientObjectException ); + } + } +} diff --git a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeTest.java b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeTest.java index c4aabe028545..4ffbe5e7402f 100644 --- a/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeTest.java +++ b/testsuite/src/test/java/org/hibernate/test/cascade/circle/MultiPathCircleCascadeTest.java @@ -109,15 +109,15 @@ public void testMergeEntityWithNonNullableTransientEntity() try { s.merge( node ); + s.getTransaction().commit(); fail( "should have thrown an exception" ); } catch ( Exception ex ) { - if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) { - assertTrue( ex instanceof TransientObjectException ); - } - else { - assertTrue( ex instanceof JDBCException ); - } + checkExceptionFromNullValueForNonNullable( + ex, + ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(), + false + ); } finally { s.getTransaction().rollback(); @@ -138,15 +138,15 @@ public void testMergeEntityWithNonNullableEntityNull() try { s.merge( node ); + s.getTransaction().commit(); fail( "should have thrown an exception" ); } catch ( Exception ex ) { - if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) { - assertTrue( ex instanceof PropertyValueException ); - } - else { - assertTrue( ex instanceof JDBCException ); - } + checkExceptionFromNullValueForNonNullable( + ex, + ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(), + true + ); } finally { s.getTransaction().rollback(); @@ -165,15 +165,15 @@ public void testMergeEntityWithNonNullablePropSetToNull() try { s.merge( route ); + s.getTransaction().commit(); fail( "should have thrown an exception" ); } catch ( Exception ex ) { - if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) { - assertTrue( ex instanceof PropertyValueException ); - } - else { - assertTrue( ex instanceof JDBCException ); - } + checkExceptionFromNullValueForNonNullable( + ex, + ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(), + true + ); } finally { s.getTransaction().rollback(); @@ -531,6 +531,20 @@ public void testMergeData3Nodes() assertUpdateCount( 1 ); } + protected void checkExceptionFromNullValueForNonNullable(Exception ex, boolean checkNullability, boolean isNullValue ) { + if ( checkNullability ) { + if ( isNullValue ) { + assertTrue( ex instanceof PropertyValueException ); + } + else { + assertTrue( ex instanceof TransientObjectException ); + } + } + else { + assertTrue( ex instanceof JDBCException ); + } + } + protected void clearCounts() { getSessions().getStatistics().clear(); } From 35eb737e21f527d69b7ed6e1cf67b0f20fae77bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarre=C3=B1o?= Date: Mon, 20 Dec 2010 11:00:45 +0100 Subject: [PATCH 2/7] HHH-5793 - Query and timestamp caches to use cluster cache loader Make evict put calls skip the cache loader since previous value is not needed. --- .../org/hibernate/cache/infinispan/util/CacheHelper.java | 4 ++-- .../org/hibernate/cache/infinispan/util/FlagAdapter.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java index 984f6c63cc81..923c2b06a2e1 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java @@ -50,12 +50,12 @@ private CacheHelper() { public static void initInternalEvict(CacheAdapter cacheAdapter, AddressAdapter member) { EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : member); - cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL).put(eKey, Internal.INIT); + cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL, FlagAdapter.SKIP_CACHE_LOAD).put(eKey, Internal.INIT); } public static void sendEvictAllNotification(CacheAdapter cacheAdapter, AddressAdapter member) { EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : member); - cacheAdapter.put(eKey, Internal.EVICT); + cacheAdapter.withFlags(FlagAdapter.SKIP_CACHE_LOAD).put(eKey, Internal.EVICT); } public static boolean isEvictAllNotification(Object key) { diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/FlagAdapter.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/FlagAdapter.java index f4f7a3a3084a..b4d329bf0f08 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/FlagAdapter.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/FlagAdapter.java @@ -36,7 +36,8 @@ public enum FlagAdapter { CACHE_MODE_LOCAL, FORCE_ASYNCHRONOUS, FORCE_SYNCHRONOUS, - SKIP_CACHE_STORE; + SKIP_CACHE_STORE, + SKIP_CACHE_LOAD; Flag toFlag() { switch(this) { @@ -50,6 +51,8 @@ Flag toFlag() { return Flag.FORCE_SYNCHRONOUS; case SKIP_CACHE_STORE: return Flag.SKIP_CACHE_STORE; + case SKIP_CACHE_LOAD: + return Flag.SKIP_CACHE_LOAD; default: throw new CacheException("Unmatched Infinispan flag " + this); } From 794fa9b5ef06b9e62155c90ceb39b27557c67905 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Mon, 20 Dec 2010 16:43:17 -0800 Subject: [PATCH 3/7] HHH-5325 : Improvements to test suite (fixes HQLDB 2.0 failures) --- .../various/readwriteexpression/Staff.java | 12 ++++++------ .../org/hibernate/test/component/basic/User.hbm.xml | 4 ++-- .../java/org/hibernate/test/filter/Product.hbm.xml | 4 ++-- .../org/hibernate/test/hql/ASTParserLoadingTest.java | 6 +++--- .../test/java/org/hibernate/test/hql/Animal.hbm.xml | 4 ++-- .../test/java/org/hibernate/test/join/Person.hbm.xml | 8 ++++---- .../org/hibernate/test/joinedsubclass/Person.hbm.xml | 8 ++++---- .../java/org/hibernate/test/legacy/FooBarTest.java | 2 +- .../java/org/hibernate/test/subselect/Beings.hbm.xml | 10 +++++----- .../org/hibernate/test/unionsubclass2/Person.hbm.xml | 8 ++++---- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java b/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java index 1f1a5265faa0..b58bac8c2b9a 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java @@ -52,24 +52,24 @@ public Staff(double sizeInInches, double radius, double diameter, Integer id) { @Column(name="size_in_cm") @ColumnTransformer( forColumn = "size_in_cm", - read = "size_in_cm / 2.54", - write = "? * 2.54" ) + read = "size_in_cm / 2.54E0", + write = "? * 2.54E0" ) public double getSizeInInches() { return sizeInInches; } public void setSizeInInches(double sizeInInches) { this.sizeInInches = sizeInInches; } private double sizeInInches; //Weird extra S to avoid potential SQL keywords @ColumnTransformer( - read = "radiusS / 2.54", - write = "? * 2.54" ) + read = "radiusS / 2.54E0", + write = "? * 2.54E0" ) public double getRadiusS() { return radiusS; } public void setRadiusS(double radiusS) { this.radiusS = radiusS; } private double radiusS; @Column(name="diamet") @ColumnTransformer( - read = "diamet / 2.54", - write = "? * 2.54" ) + read = "diamet / 2.54E0", + write = "? * 2.54E0" ) public double getDiameter() { return diameter; } public void setDiameter(double diameter) { this.diameter = diameter; } private double diameter; diff --git a/testsuite/src/test/java/org/hibernate/test/component/basic/User.hbm.xml b/testsuite/src/test/java/org/hibernate/test/component/basic/User.hbm.xml index 85839a6956f1..255df217052a 100755 --- a/testsuite/src/test/java/org/hibernate/test/component/basic/User.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/component/basic/User.hbm.xml @@ -22,8 +22,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> + write="0.453E0 * ?" + read="weight_kg / 0.453E0"/> diff --git a/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java b/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java index d52a8338b06a..41c2629bfec2 100644 --- a/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java +++ b/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java @@ -307,7 +307,7 @@ public void testComponentNullnessChecks() { results = s.createQuery( "from Human where name is not null" ).list(); assertEquals( 3, results.size() ); String query = - getDialect() instanceof DB2Dialect ? + ( getDialect() instanceof DB2Dialect || getDialect() instanceof HSQLDialect ) ? "from Human where cast(? as string) is null" : "from Human where ? is null" ; @@ -2510,14 +2510,14 @@ public void testEJBQLFunctions() throws Exception { * PostgreSQL >= 8.3.7 typecasts are no longer automatically allowed * http://www.postgresql.org/docs/current/static/release-8-3.html */ - if(getDialect() instanceof PostgreSQLDialect){ + if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){ hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24"; }else{ hql = "from Animal a where bit_length(a.bodyWeight) = 24"; } session.createQuery(hql).list(); - if(getDialect() instanceof PostgreSQLDialect){ + if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){ hql = "select bit_length(str(a.bodyWeight)) from Animal a"; }else{ hql = "select bit_length(a.bodyWeight) from Animal a"; diff --git a/testsuite/src/test/java/org/hibernate/test/hql/Animal.hbm.xml b/testsuite/src/test/java/org/hibernate/test/hql/Animal.hbm.xml index 94411be0db75..71e693d3489d 100644 --- a/testsuite/src/test/java/org/hibernate/test/hql/Animal.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/hql/Animal.hbm.xml @@ -50,8 +50,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> diff --git a/testsuite/src/test/java/org/hibernate/test/join/Person.hbm.xml b/testsuite/src/test/java/org/hibernate/test/join/Person.hbm.xml index bf9bf03ca101..227f1456ed92 100755 --- a/testsuite/src/test/java/org/hibernate/test/join/Person.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/join/Person.hbm.xml @@ -39,8 +39,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> @@ -73,8 +73,8 @@ + read="pwd_expiry_weeks * 7.0E0" + write="? / 7.0E0"/> diff --git a/testsuite/src/test/java/org/hibernate/test/joinedsubclass/Person.hbm.xml b/testsuite/src/test/java/org/hibernate/test/joinedsubclass/Person.hbm.xml index bb60f51dd316..99845abb2590 100755 --- a/testsuite/src/test/java/org/hibernate/test/joinedsubclass/Person.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/joinedsubclass/Person.hbm.xml @@ -38,8 +38,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> @@ -58,8 +58,8 @@ + read="pwd_expiry_weeks * 7.0E0" + write="? / 7.0E0"/> diff --git a/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java index 595081c4d9ff..36eaa50ba2f9 100644 --- a/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java +++ b/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java @@ -1940,7 +1940,7 @@ public void testFindByCriteria() throws Exception { .addOrder( Order.asc("date") ) .list(); assertTrue( list.size()==1 && list.get(0)==f ); - if(!(getDialect() instanceof TimesTenDialect)) { + if(!(getDialect() instanceof TimesTenDialect || getDialect() instanceof HSQLDialect)) { list = s.createCriteria(Foo.class).setMaxResults(0).list(); assertTrue( list.size()==0 ); } diff --git a/testsuite/src/test/java/org/hibernate/test/subselect/Beings.hbm.xml b/testsuite/src/test/java/org/hibernate/test/subselect/Beings.hbm.xml index 10a875205822..adc3ebc2a732 100755 --- a/testsuite/src/test/java/org/hibernate/test/subselect/Beings.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/subselect/Beings.hbm.xml @@ -39,8 +39,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> @@ -62,8 +62,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> @@ -92,7 +92,7 @@ + read="height_centimeters / 2.54E0"/> diff --git a/testsuite/src/test/java/org/hibernate/test/unionsubclass2/Person.hbm.xml b/testsuite/src/test/java/org/hibernate/test/unionsubclass2/Person.hbm.xml index dced315daeac..bda7e1880345 100755 --- a/testsuite/src/test/java/org/hibernate/test/unionsubclass2/Person.hbm.xml +++ b/testsuite/src/test/java/org/hibernate/test/unionsubclass2/Person.hbm.xml @@ -37,8 +37,8 @@ + read="height_centimeters / 2.54E0" + write="? * 2.54E0"/> @@ -56,8 +56,8 @@ + read="pwd_expiry_weeks * 7.0E0" + write="? / 7.0E0"/> From 5e556466ba65d868a5c76b8e6eef5303651519c7 Mon Sep 17 00:00:00 2001 From: Erik-Berndt Scheper Date: Wed, 22 Dec 2010 10:54:00 +0100 Subject: [PATCH 4/7] HHH-5750 - Proxied objects lose the temporary session used to initialize them --- .../org/hibernate/envers/tools/Tools.java | 1 - .../proxy/AuditedCollectionProxyTest.java | 76 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java diff --git a/envers/src/main/java/org/hibernate/envers/tools/Tools.java b/envers/src/main/java/org/hibernate/envers/tools/Tools.java index 6a420588b349..cffe0fcd0a58 100644 --- a/envers/src/main/java/org/hibernate/envers/tools/Tools.java +++ b/envers/src/main/java/org/hibernate/envers/tools/Tools.java @@ -82,7 +82,6 @@ public static Object getTargetFromProxy(SessionFactoryImplementor sessionFactory proxy.getHibernateLazyInitializer().getEntityName(), proxy.getHibernateLazyInitializer().getIdentifier() ); - proxy.getHibernateLazyInitializer().setImplementation( target ); return target; } finally { diff --git a/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java b/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java new file mode 100644 index 000000000000..da0dab29ebcf --- /dev/null +++ b/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java @@ -0,0 +1,76 @@ +package org.hibernate.envers.test.integration.proxy; + +import javax.persistence.EntityManager; + +import org.hibernate.ejb.Ejb3Configuration; +import org.hibernate.envers.test.AbstractEntityTest; +import org.hibernate.envers.test.entities.onetomany.ListRefEdEntity; +import org.hibernate.envers.test.entities.onetomany.ListRefIngEntity; +import org.hibernate.proxy.HibernateProxy; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Test case for HHH-5750: Proxied objects lose the temporary session used to + * initialize them. + * + * @author Erik-Berndt Scheper + * + */ +public class AuditedCollectionProxyTest extends AbstractEntityTest { + + Integer id_ListRefEdEntity1; + + public void configure(Ejb3Configuration cfg) { + cfg.addAnnotatedClass(ListRefEdEntity.class); + cfg.addAnnotatedClass(ListRefIngEntity.class); + } + + @BeforeClass(dependsOnMethods = "init") + public void initData() { + EntityManager em = getEntityManager(); + + ListRefEdEntity listReferencedEntity1 = new ListRefEdEntity( + Integer.valueOf(1), "str1"); + ListRefIngEntity refingEntity1 = new ListRefIngEntity( + Integer.valueOf(1), "refing1", listReferencedEntity1); + + // Revision 1 + em.getTransaction().begin(); + em.persist(listReferencedEntity1); + em.persist(refingEntity1); + em.getTransaction().commit(); + + id_ListRefEdEntity1 = listReferencedEntity1.getId(); + + // Revision 2 + ListRefIngEntity refingEntity2 = new ListRefIngEntity( + Integer.valueOf(2), "refing2", listReferencedEntity1); + + em.getTransaction().begin(); + em.persist(refingEntity2); + em.getTransaction().commit(); + } + + @Test + public void testProxyIdentifier() { + EntityManager em = getEntityManager(); + + ListRefEdEntity listReferencedEntity1 = em.getReference( + ListRefEdEntity.class, id_ListRefEdEntity1); + + assert listReferencedEntity1 instanceof HibernateProxy; + + // Revision 3 + ListRefIngEntity refingEntity3 = new ListRefIngEntity( + Integer.valueOf(3), "refing3", listReferencedEntity1); + + em.getTransaction().begin(); + em.persist(refingEntity3); + em.getTransaction().commit(); + + listReferencedEntity1.getReffering().size(); + + } + +} From db62fa7dbe7c684ab3c9bfecc99780c7de08da24 Mon Sep 17 00:00:00 2001 From: Erik-Berndt Scheper Date: Wed, 22 Dec 2010 11:51:04 +0100 Subject: [PATCH 5/7] HHH-5750 - Added license header --- .../proxy/AuditedCollectionProxyTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java b/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java index da0dab29ebcf..3c009f5bdcc3 100644 --- a/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java +++ b/envers/src/test/java/org/hibernate/envers/test/integration/proxy/AuditedCollectionProxyTest.java @@ -1,3 +1,26 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Middleware LLC. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.envers.test.integration.proxy; import javax.persistence.EntityManager; From cc3830d18b9ca0c71fb5da6ae2729097e8256ceb Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Thu, 23 Dec 2010 17:51:50 +0800 Subject: [PATCH 6/7] HHH-5806 mapping static inner class causes hsqldb tests fails --- parent/pom.xml | 2 +- .../test/annotations/generics/Classes.java | 9 +++++++ .../src/test/resources/hibernate.properties | 27 ++++++++++++++----- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index cea3e10a79ea..8f6f848f9117 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -574,7 +574,7 @@ org.hsqldb hsqldb - 2.0.0 + 2.0.1-rc3 test diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/generics/Classes.java b/testsuite/src/test/java/org/hibernate/test/annotations/generics/Classes.java index 34c4073cc859..25d51c4359b9 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/generics/Classes.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/generics/Classes.java @@ -16,15 +16,21 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; public class Classes { @Embeddable + @Table(name="Edition") public static class Edition { T name; } + @Entity + @Table(name="Book") public static class Book { @Id @GeneratedValue(strategy=GenerationType.AUTO) @@ -35,12 +41,15 @@ public static class Book { } @Entity + @Table(name="PopularBook") public static class PopularBook { @Id @GeneratedValue(strategy=GenerationType.AUTO) Long id; @ElementCollection + @JoinTable(name="PopularBook_Editions",joinColumns={@JoinColumn(name="PopularBook_id")}) + Set> editions = new HashSet>(); } } diff --git a/testsuite/src/test/resources/hibernate.properties b/testsuite/src/test/resources/hibernate.properties index fe834c715820..a07724225d54 100644 --- a/testsuite/src/test/resources/hibernate.properties +++ b/testsuite/src/test/resources/hibernate.properties @@ -13,13 +13,28 @@ # # # Red Hat Author(s): Steve Ebersole # ################################################################################ -hibernate.dialect ${db.dialect} -hibernate.connection.driver_class ${jdbc.driver} -hibernate.connection.url ${jdbc.url} -hibernate.connection.username ${jdbc.user} -hibernate.connection.password ${jdbc.pass} -hibernate.connection.isolation ${jdbc.isolation} +## H2 +hibernate.dialect org.hibernate.dialect.H2Dialect +hibernate.connection.driver_class org.h2.Driver +hibernate.connection.username sa +hibernate.connection.password +hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE + + +## Oracle 10g +#hibernate.dialect org.hibernate.dialect.Oracle10gDialect +#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver +#hibernate.connection.username stliu +#hibernate.connection.password stliu +#hibernate.connection.url jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10 + +## HypersonicSQL +hibernate.dialect org.hibernate.dialect.HSQLDialect +hibernate.connection.driver_class org.hsqldb.jdbcDriver +hibernate.connection.username sa +hibernate.connection.password +hibernate.connection.url jdbc:hsqldb:test hibernate.connection.pool_size 5 From f3feba66ced11b79de963756325d8d2c1e4beac2 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Thu, 23 Dec 2010 18:13:06 +0800 Subject: [PATCH 7/7] HHH-5806 rollback the test info --- parent/pom.xml | 2 +- .../src/test/resources/hibernate.properties | 28 ++++--------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 8f6f848f9117..cea3e10a79ea 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -574,7 +574,7 @@ org.hsqldb hsqldb - 2.0.1-rc3 + 2.0.0 test diff --git a/testsuite/src/test/resources/hibernate.properties b/testsuite/src/test/resources/hibernate.properties index a07724225d54..b6eeb1a820f2 100644 --- a/testsuite/src/test/resources/hibernate.properties +++ b/testsuite/src/test/resources/hibernate.properties @@ -13,28 +13,12 @@ # # # Red Hat Author(s): Steve Ebersole # ################################################################################ -## H2 -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver -hibernate.connection.username sa -hibernate.connection.password - -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE - - -## Oracle 10g -#hibernate.dialect org.hibernate.dialect.Oracle10gDialect -#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver -#hibernate.connection.username stliu -#hibernate.connection.password stliu -#hibernate.connection.url jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10 - -## HypersonicSQL -hibernate.dialect org.hibernate.dialect.HSQLDialect -hibernate.connection.driver_class org.hsqldb.jdbcDriver -hibernate.connection.username sa -hibernate.connection.password -hibernate.connection.url jdbc:hsqldb:test +hibernate.dialect ${db.dialect} +hibernate.connection.driver_class ${jdbc.driver} +hibernate.connection.url ${jdbc.url} +hibernate.connection.username ${jdbc.user} +hibernate.connection.password ${jdbc.pass} +hibernate.connection.isolation ${jdbc.isolation} hibernate.connection.pool_size 5