diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/BaseChild.java b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/BaseChild.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/BaseChild.java rename to hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/BaseChild.java index 6d6ee8eff2..19caf1f1d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/BaseChild.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/BaseChild.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.lazynocascadecache; +package org.hibernate.test.collection.lazynocascade; /** * @author Vasily Kochnev diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Child.java b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Child.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Child.java rename to hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Child.java index 2ec94c4745..b716e81b77 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Child.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Child.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.lazynocascadecache; +package org.hibernate.test.collection.lazynocascade; /** * @author Vasily Kochnev diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/LazyNoCascadeCacheTest.java b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/LazyAssociationNoCascadeTest.java similarity index 71% rename from hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/LazyNoCascadeCacheTest.java rename to hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/LazyAssociationNoCascadeTest.java index 34b82b49bc..4334c51eeb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/LazyNoCascadeCacheTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/LazyAssociationNoCascadeTest.java @@ -21,21 +21,22 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.lazynocascadecache; +package org.hibernate.test.collection.lazynocascade; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.hibernate.Session; -import org.hibernate.Transaction; - -import org.junit.Test; - import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; /** * @author Vasily Kochnev */ -public class LazyNoCascadeCacheTest extends BaseCoreFunctionalTestCase { +public class LazyAssociationNoCascadeTest extends BaseCoreFunctionalTestCase { + public String[] getMappings() { - return new String[] {"lazynocascadecache/Parent.hbm.xml"}; + return new String[] {"collection/lazynocascade/Parent.hbm.xml"}; } @Test @@ -44,17 +45,25 @@ public class LazyNoCascadeCacheTest extends BaseCoreFunctionalTestCase { BaseChild firstChild = new BaseChild(); parent.getChildren().add( firstChild ); + + Session s = openSession(); + s.beginTransaction(); + s.save(parent); + s.getTransaction().commit(); + s.clear(); Child secondChild = new Child(); secondChild.setName( "SecondChildName" ); - parent.getChildren().add( secondChild );//Dependency child must go after dependent in collection + parent.getChildren().add( secondChild ); firstChild.setDependency( secondChild ); - Session s = openSession(); - Transaction t = s.beginTransaction(); - s.merge( parent ); - t.commit(); + s.beginTransaction(); + Parent mergedParent = (Parent) s.merge( parent ); + s.getTransaction().commit(); s.close(); + + assertNotNull( mergedParent ); + assertEquals( mergedParent.getChildren().size(), 2 ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.hbm.xml similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.hbm.xml rename to hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.hbm.xml index 507b3448ca..4ef56805b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.hbm.xml @@ -2,7 +2,7 @@ - + diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.java b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.java rename to hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.java index d318abb1df..666b2c3494 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lazynocascadecache/Parent.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/lazynocascade/Parent.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.lazynocascadecache; +package org.hibernate.test.collection.lazynocascade; import java.util.LinkedHashSet; import java.util.Set;