HHH-8573 refactored test case

This commit is contained in:
Brett Meyer 2013-10-16 17:21:00 -04:00
parent af03365c86
commit a1e3849e5d
5 changed files with 25 additions and 16 deletions

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.lazynocascadecache; package org.hibernate.test.collection.lazynocascade;
/** /**
* @author Vasily Kochnev * @author Vasily Kochnev

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.lazynocascadecache; package org.hibernate.test.collection.lazynocascade;
/** /**
* @author Vasily Kochnev * @author Vasily Kochnev

View File

@ -21,21 +21,22 @@
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * 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.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/** /**
* @author Vasily Kochnev * @author Vasily Kochnev
*/ */
public class LazyNoCascadeCacheTest extends BaseCoreFunctionalTestCase { public class LazyAssociationNoCascadeTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] {"lazynocascadecache/Parent.hbm.xml"}; return new String[] {"collection/lazynocascade/Parent.hbm.xml"};
} }
@Test @Test
@ -44,17 +45,25 @@ public class LazyNoCascadeCacheTest extends BaseCoreFunctionalTestCase {
BaseChild firstChild = new BaseChild(); BaseChild firstChild = new BaseChild();
parent.getChildren().add( firstChild ); parent.getChildren().add( firstChild );
Session s = openSession();
s.beginTransaction();
s.save(parent);
s.getTransaction().commit();
s.clear();
Child secondChild = new Child(); Child secondChild = new Child();
secondChild.setName( "SecondChildName" ); secondChild.setName( "SecondChildName" );
parent.getChildren().add( secondChild );//Dependency child must go after dependent in collection parent.getChildren().add( secondChild );
firstChild.setDependency( secondChild ); firstChild.setDependency( secondChild );
Session s = openSession(); s.beginTransaction();
Transaction t = s.beginTransaction(); Parent mergedParent = (Parent) s.merge( parent );
s.merge( parent ); s.getTransaction().commit();
t.commit();
s.close(); s.close();
assertNotNull( mergedParent );
assertEquals( mergedParent.getChildren().size(), 2 );
} }
} }

View File

@ -2,7 +2,7 @@
<!DOCTYPE hibernate-mapping PUBLIC <!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.test.lazynocascadecache"> <hibernate-mapping package="org.hibernate.test.collection.lazynocascade">
<class name="Parent"> <class name="Parent">
<id name="id" column="parent_id"> <id name="id" column="parent_id">
<generator class="increment"/> <generator class="increment"/>

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.lazynocascadecache; package org.hibernate.test.collection.lazynocascade;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;