Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 17:00:41 -0500 (Mon, 06 Nov 2006)
New Revision: 10739
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/BagOwner.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/Mappings.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/IdbagOwner.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/Mappings.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/ListOwner.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/Mappings.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentBag.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentIdentifierBag.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentList.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
Log:
HHH-2217 : PersistentCollection mutation methods and dirtying
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentBag.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentBag.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentBag.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -284,8 +284,14 @@
* @see java.util.Collection#remove(Object)
*/
public boolean remove(Object o) {
- write();
- return bag.remove(o);
+ initialize( true );
+ if ( bag.remove( o ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
/**
@@ -319,8 +325,14 @@
*/
public boolean removeAll(Collection c) {
if ( c.size()>0 ) {
- write();
- return bag.removeAll(c);
+ initialize( true );
+ if ( bag.removeAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else {
return false;
@@ -331,8 +343,14 @@
* @see java.util.Collection#retainAll(Collection)
*/
public boolean retainAll(Collection c) {
- write();
- return bag.retainAll(c);
+ initialize( true );
+ if ( bag.retainAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
/**
@@ -343,8 +361,11 @@
queueOperation( new Clear() );
}
else {
- write();
- bag.clear();
+ initialize( true );
+ if ( ! bag.isEmpty() ) {
+ bag.clear();
+ dirty();
+ }
}
}
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentIdentifierBag.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentIdentifierBag.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentIdentifierBag.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -88,9 +88,12 @@
}
public void clear() {
- write();
- values.clear();
- identifiers.clear();
+ initialize( true );
+ if ( ! values.isEmpty() || ! identifiers.isEmpty() ) {
+ values.clear();
+ identifiers.clear();
+ dirty();
+ }
}
public boolean contains(Object o) {
@@ -113,11 +116,12 @@
}
public boolean remove(Object o) {
- write();
+ initialize( true );
int index = values.indexOf(o);
if (index>=0) {
beforeRemove(index);
values.remove(index);
+ dirty();
return true;
}
else {
@@ -126,9 +130,7 @@
}
public boolean removeAll(Collection c) {
- if ( c.size()>0 ) {
- //write();
- //return values.removeAll(c);
+ if ( c.size() > 0 ) {
boolean result = false;
Iterator iter = c.iterator();
while ( iter.hasNext() ) {
@@ -142,8 +144,14 @@
}
public boolean retainAll(Collection c) {
- write();
- return values.retainAll(c);
+ initialize( true );
+ if ( values.retainAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
public int size() {
@@ -308,11 +316,11 @@
}
public boolean addAll(int index, Collection c) {
- if ( c.size()>0 ) {
- //write();
- //return values.addAll(index, c);
+ if ( c.size() > 0 ) {
Iterator iter = c.iterator();
- while ( iter.hasNext() ) add( index++, iter.next() );
+ while ( iter.hasNext() ) {
+ add( index++, iter.next() );
+ }
return true;
}
else {
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentList.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentList.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/collection/PersistentList.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -150,11 +150,16 @@
* @see java.util.List#remove(Object)
*/
public boolean remove(Object value) {
- Boolean exists = isPutQueueEnabled() ?
- readElementExistence(value) : null;
- if ( exists==null ) {
- write();
- return list.remove(value);
+ Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
+ if ( exists == null ) {
+ initialize( true );
+ if ( list.remove( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else if ( exists.booleanValue() ) {
queueOperation( new SimpleRemove(value) );
@@ -177,7 +182,9 @@
* @see java.util.List#addAll(Collection)
*/
public boolean addAll(Collection values) {
- if ( values.size()==0 ) return false;
+ if ( values.size()==0 ) {
+ return false;
+ }
if ( !isOperationQueueEnabled() ) {
write();
return list.addAll(values);
@@ -209,8 +216,14 @@
*/
public boolean removeAll(Collection coll) {
if ( coll.size()>0 ) {
- write();
- return list.removeAll(coll);
+ initialize( true );
+ if ( list.removeAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else {
return false;
@@ -221,8 +234,14 @@
* @see java.util.List#retainAll(Collection)
*/
public boolean retainAll(Collection coll) {
- write();
- return list.retainAll(coll);
+ initialize( true );
+ if ( list.retainAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
/**
@@ -233,8 +252,11 @@
queueOperation( new Clear() );
}
else {
- write();
- list.clear();
+ initialize( true );
+ if ( ! list.isEmpty() ) {
+ list.clear();
+ dirty();
+ }
}
}
@@ -256,8 +278,7 @@
if (index<0) {
throw new ArrayIndexOutOfBoundsException("negative index");
}
- Object old = isPutQueueEnabled() ?
- readElementByIndex( new Integer(index) ) : UNKNOWN;
+ Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN;
if ( old==UNKNOWN ) {
write();
return list.set(index, value);
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -2,11 +2,15 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+
+import org.hibernate.test.collection.bag.PersistentBagTest;
+import org.hibernate.test.collection.idbag.PersistentIdBagTest;
+import org.hibernate.test.collection.list.PersistentListTest;
import org.hibernate.test.collection.map.PersistentMapTest;
import org.hibernate.test.collection.set.PersistentSetTest;
/**
- * todo: describe CollectionSuite
+ * Suite of collection (esp PersistentCollection) related tests
*
* @author Steve Ebersole
*/
@@ -15,6 +19,9 @@
public static Test suite() {
TestSuite suite = new TestSuite( "Collection-related tests" );
suite.addTest( CollectionTest.suite() );
+ suite.addTest( PersistentBagTest.suite() );
+ suite.addTest( PersistentIdBagTest.suite() );
+ suite.addTest( PersistentListTest.suite() );
suite.addTest( PersistentMapTest.suite() );
suite.addTest( PersistentSetTest.suite() );
return suite;
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/BagOwner.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/BagOwner.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/BagOwner.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,46 @@
+package org.hibernate.test.collection.bag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class BagOwner {
+ private String name;
+ private BagOwner parent;
+ private List children = new ArrayList();
+
+ public BagOwner() {
+ }
+
+ public BagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BagOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(BagOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/Mappings.hbm.xml
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/Mappings.hbm.xml 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/Mappings.hbm.xml 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="org.hibernate.test.collection.bag">
+
+ <class name="BagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="BagOwner"
cascade="none" />
+
+ <bag name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="BagOwner" />
+ </bag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/bag/PersistentBagTest.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,71 @@
+package org.hibernate.test.collection.bag;
+
+import java.util.HashSet;
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentBag;
+
+/**
+ * Tests related to operations on a PersistentBag.
+ *
+ * @author Steve Ebersole
+ */
+public class PersistentBagTest extends TestCase {
+ public PersistentBagTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "collection/bag/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( PersistentBagTest.class );
+ }
+
+ public void testWriteMethodDirtying() {
+ BagOwner parent = new BagOwner( "root" );
+ BagOwner child = new BagOwner( "c1" );
+ parent.getChildren().add( child );
+ child.setParent( parent );
+ BagOwner otherChild = new BagOwner( "c2" );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.flush();
+ // at this point, the list on parent has now been replaced with a PersistentBag...
+ PersistentBag children = ( PersistentBag ) parent.getChildren();
+
+ assertFalse( children.remove( otherChild ) );
+ assertFalse( children.isDirty() );
+
+ ArrayList otherCollection = new ArrayList();
+ otherCollection.add( child );
+ assertFalse( children.retainAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ otherCollection = new ArrayList();
+ otherCollection.add( otherChild );
+ assertFalse( children.removeAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ children.clear();
+ session.delete( child );
+ assertTrue( children.isDirty() );
+
+ session.flush();
+
+ children.clear();
+ assertFalse( children.isDirty() );
+
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
+}
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/IdbagOwner.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/IdbagOwner.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/IdbagOwner.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,37 @@
+package org.hibernate.test.collection.idbag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class IdbagOwner {
+ private String name;
+ private List children = new ArrayList();
+
+ public IdbagOwner() {
+ }
+
+ public IdbagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/Mappings.hbm.xml
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/Mappings.hbm.xml 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/Mappings.hbm.xml 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="org.hibernate.test.collection.idbag">
+
+ <class name="IdbagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <idbag name="children" cascade="all"
table="idbag_owner_children">
+ <collection-id column="CHILD" type="long">
+ <generator class="increment"/>
+ </collection-id>
+ <key column="PARENT_FK" />
+ <many-to-many column="CHILD_FK" class="IdbagOwner"
/>
+ </idbag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/idbag/PersistentIdBagTest.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,69 @@
+package org.hibernate.test.collection.idbag;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentIdentifierBag;
+
+/**
+ * Tests related to operations on a PersistentIdentifierBag
+ *
+ * @author Steve Ebersole
+ */
+public class PersistentIdBagTest extends TestCase {
+ public PersistentIdBagTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "collection/idbag/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( PersistentIdBagTest.class );
+ }
+
+ public void testWriteMethodDirtying() {
+ IdbagOwner parent = new IdbagOwner( "root" );
+ IdbagOwner child = new IdbagOwner( "c1" );
+ parent.getChildren().add( child );
+ IdbagOwner otherChild = new IdbagOwner( "c2" );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.flush();
+ // at this point, the list on parent has now been replaced with a PersistentBag...
+ PersistentIdentifierBag children = ( PersistentIdentifierBag ) parent.getChildren();
+
+ assertFalse( children.remove( otherChild ) );
+ assertFalse( children.isDirty() );
+
+ ArrayList otherCollection = new ArrayList();
+ otherCollection.add( child );
+ assertFalse( children.retainAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ otherCollection = new ArrayList();
+ otherCollection.add( otherChild );
+ assertFalse( children.removeAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ children.clear();
+ session.delete( child );
+ assertTrue( children.isDirty() );
+
+ session.flush();
+
+ children.clear();
+ assertFalse( children.isDirty() );
+
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
+}
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/ListOwner.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/ListOwner.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/ListOwner.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,46 @@
+package org.hibernate.test.collection.list;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ListOwner {
+ private String name;
+ private ListOwner parent;
+ private List children = new ArrayList();
+
+ public ListOwner() {
+ }
+
+ public ListOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ListOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(ListOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/Mappings.hbm.xml
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/Mappings.hbm.xml 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/Mappings.hbm.xml 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="org.hibernate.test.collection.list">
+
+ <class name="ListOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="ListOwner"
cascade="none" />
+
+ <list name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <list-index column="LIST_INDEX"/>
+ <one-to-many class="ListOwner" />
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java
===================================================================
---
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-11-06
21:56:38 UTC (rev 10738)
+++
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/collection/list/PersistentListTest.java 2006-11-06
22:00:41 UTC (rev 10739)
@@ -0,0 +1,70 @@
+package org.hibernate.test.collection.list;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentList;
+
+/**
+ * Tests related to operations on a PersistentList
+ *
+ * @author Steve Ebersole
+ */
+public class PersistentListTest extends TestCase {
+ public PersistentListTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "collection/list/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( PersistentListTest.class );
+ }
+
+ public void testWriteMethodDirtying() {
+ ListOwner parent = new ListOwner( "root" );
+ ListOwner child = new ListOwner( "c1" );
+ parent.getChildren().add( child );
+ child.setParent( parent );
+ ListOwner otherChild = new ListOwner( "c2" );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.flush();
+ // at this point, the list on parent has now been replaced with a PersistentList...
+ PersistentList children = ( PersistentList ) parent.getChildren();
+
+ assertFalse( children.remove( otherChild ) );
+ assertFalse( children.isDirty() );
+
+ ArrayList otherCollection = new ArrayList();
+ otherCollection.add( child );
+ assertFalse( children.retainAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ otherCollection = new ArrayList();
+ otherCollection.add( otherChild );
+ assertFalse( children.removeAll( otherCollection ) );
+ assertFalse( children.isDirty() );
+
+ children.clear();
+ session.delete( child );
+ assertTrue( children.isDirty() );
+
+ session.flush();
+
+ children.clear();
+ assertFalse( children.isDirty() );
+
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
+}