[hibernate-commits] Hibernate SVN: r14302 - in core/branches/Branch_3_2: src/org/hibernate/event and 3 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jan 30 20:13:45 EST 2008


Author: gbadner
Date: 2008-01-30 20:13:44 -0500 (Wed, 30 Jan 2008)
New Revision: 14302

Added:
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Entity.java
Modified:
   core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java
   core/branches/Branch_3_2/src/org/hibernate/hibernate-configuration-3.0.dtd
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/AbstractCollectionEventTest.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/BrokenCollectionEventTest.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Child.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildEntity.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildValue.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ParentWithCollection.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/AbstractAssociationCollectionEventTest.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/manytomany/ChildWithBidirectionalManyToMany.java
Log:
HHH-2616 : add new collection events to hibernate-configuration-3.0.dtd; added accessor for affected owner ID to AbstractCollectionEvent



Modified: core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -1,6 +1,8 @@
 //$Id: $
 package org.hibernate.event;
 
+import java.io.Serializable;
+
 import org.hibernate.collection.PersistentCollection;
 import org.hibernate.engine.SessionImplementor;
 
@@ -13,11 +15,14 @@
 
 	private final PersistentCollection collection;
 	private final Object affectedOwner;
+	private final Serializable affectedOwnerId;
 
-    public AbstractCollectionEvent(PersistentCollection collection, EventSource source, Object affectedOwner) {
+	public AbstractCollectionEvent(PersistentCollection collection, EventSource source, Object affectedOwner) {
 		super(source);
 		this.collection = collection;
 		this.affectedOwner = affectedOwner;
+		this.affectedOwnerId =
+				( ( SessionImplementor ) source ).getPersistenceContext().getEntry( affectedOwner ).getId();
 	}
 
 	protected static Object getLoadedOwner( PersistentCollection collection, EventSource source ) {
@@ -31,4 +36,8 @@
 	public Object getAffectedOwner() {
 		return affectedOwner;
 	}
+
+	public Serializable getAffectedOwnerId() {
+		return affectedOwnerId;
+	}
 }

Modified: core/branches/Branch_3_2/src/org/hibernate/hibernate-configuration-3.0.dtd
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/hibernate-configuration-3.0.dtd	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/src/org/hibernate/hibernate-configuration-3.0.dtd	2008-01-31 01:13:44 UTC (rev 14302)
@@ -34,10 +34,10 @@
 <!ATTLIST collection-cache usage (read-only|read-write|nonstrict-read-write|transactional) #REQUIRED>
 
 <!ELEMENT event (listener*)>
-<!ATTLIST event type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|post-load|post-update|post-insert|post-delete|post-commit-update|post-commit-insert|post-commit-delete) #REQUIRED>
+<!ATTLIST event type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|pre-collection-recreate|pre-collection-remove|pre-collection-update|post-load|post-update|post-insert|post-delete|post-collection-recreate|post-collection-remove|post-collection-update|post-commit-update|post-commit-insert|post-commit-delete) #REQUIRED>
 
 <!ELEMENT listener EMPTY>
-<!ATTLIST listener type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|post-load|post-update|post-insert|post-delete|post-commit-update|post-commit-insert|post-commit-delete) #IMPLIED>
+<!ATTLIST listener type (auto-flush|merge|create|create-onflush|delete|dirty-check|evict|flush|flush-entity|load|load-collection|lock|refresh|replicate|save-update|save|update|pre-load|pre-update|pre-insert|pre-delete|pre-collection-recreate|pre-collection-remove|pre-collection-update|post-load|post-update|post-insert|post-delete|post-collection-recreate|post-collection-remove|post-collection-update|post-commit-update|post-commit-insert|post-commit-delete) #IMPLIED>
 <!ATTLIST listener class CDATA #REQUIRED>
 
 <!ELEMENT session-factory (property*, mapping*, (class-cache|collection-cache)*, event*, listener*)>

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/AbstractCollectionEventTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/AbstractCollectionEventTest.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/AbstractCollectionEventTest.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -94,9 +94,9 @@
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
 		Child child = ( Child ) parent.getChildren().iterator().next();
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -119,9 +119,9 @@
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( newChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( newChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -143,9 +143,9 @@
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( newChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( newChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -167,9 +167,9 @@
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( newChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( newChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -183,8 +183,8 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( Child ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		parent.addChild( child );
 		tx.commit();
@@ -193,16 +193,20 @@
 		if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( child ) ).wasInitialized() ) {
-				checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		ChildWithBidirectionalManyToMany childWithManyToMany = null;
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;
+			if ( ( ( PersistentCollection ) childWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );
+			}
 		}
 		if ( !( parent.getChildren() instanceof PersistentSet ) ) {
 			checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 			checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() && !( getParents( child ) instanceof PersistentSet ) ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( childWithManyToMany != null && !( childWithManyToMany.getParents() instanceof PersistentSet ) ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), childWithManyToMany, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), childWithManyToMany, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -226,9 +230,9 @@
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, collectionOrig, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, collectionOrig, index++ );
-		if ( newChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( newChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
@@ -254,9 +258,9 @@
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( newChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( newChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
@@ -272,8 +276,8 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( ChildEntity ) s.get( child.getClass(), ( ( ChildEntity ) child).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child).getId() );
 		}
 		Collection oldCollection = parent.getChildren();
 		parent.newChildren( createCollection() );
@@ -284,16 +288,19 @@
 		if ( ( ( PersistentCollection ) oldCollection ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany()  && ( ( PersistentCollection ) getParents( child ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			ChildWithBidirectionalManyToMany childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;
+			if ( ( ( PersistentCollection ) childWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
 			// hmmm, the same parent was removed and re-added to the child's collection;
 			// should this be considered an update?
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
@@ -309,8 +316,8 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( oldChild instanceof ChildEntity ) {
-			oldChild = ( ChildEntity ) s.get( oldChild.getClass(), ( ( ChildEntity ) oldChild).getId() );
+		if ( oldChild instanceof Entity ) {
+			oldChild = ( Child ) s.get( oldChild.getClass(), ( ( Entity ) oldChild).getId() );
 		}
 		Collection oldCollection = parent.getChildren();
 		parent.newChildren( createCollection() );
@@ -321,16 +328,19 @@
 		if ( ( ( PersistentCollection ) oldCollection ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++ );
 		}
-		if ( oldChild.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( oldChild ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), oldChild, index++ );
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			ChildWithBidirectionalManyToMany oldChildWithManyToMany = ( ChildWithBidirectionalManyToMany ) oldChild;
+			if ( ( ( PersistentCollection ) oldChildWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), oldChildWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( oldChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPreCollectionRecreateListener(), newChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionRecreateListener(), newChild, index++ );
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
+			checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
@@ -346,8 +356,8 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( Child ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		parent.removeChild( child );
 		tx.commit();
@@ -356,14 +366,17 @@
 		if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( child ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			ChildWithBidirectionalManyToMany childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;
+			if ( ( ( PersistentCollection ) childWithManyToMany.getParents( ) ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -377,8 +390,8 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( Child ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		parent.clearChildren();
 		tx.commit();
@@ -387,14 +400,17 @@
 		if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( child ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			ChildWithBidirectionalManyToMany childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;
+			if ( ( ( PersistentCollection ) childWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -415,8 +431,8 @@
 		s = openSession();
 		tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( oldChild instanceof ChildEntity ) {
-			oldChild = ( Child ) s.get( oldChild.getClass(), ( ( ChildEntity ) oldChild ).getId() );
+		if ( oldChild instanceof Entity ) {
+			oldChild = ( Child ) s.get( oldChild.getClass(), ( ( Entity ) oldChild ).getId() );
 		}
 		parent.removeChild( oldChild );
 		tx.commit();
@@ -425,14 +441,17 @@
 		if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
 		}
-		if ( oldChild.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( oldChild ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), oldChild, index++ );
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			ChildWithBidirectionalManyToMany oldChildWithManyToMany = ( ChildWithBidirectionalManyToMany ) oldChild;
+			if ( ( ( PersistentCollection ) oldChildWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), oldChildWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
-		if ( oldChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChild, index++ );
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -479,11 +498,11 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( Child ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		parent.removeChild( child );
-		if ( child instanceof ChildEntity ) {
+		if ( child instanceof Entity ) {
 			s.delete( child );
 		}
 		s.delete( parent );
@@ -491,14 +510,14 @@
 		s.close();
 		int index = 0;
 		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionRemoveListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionRemoveListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionRemoveListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionRemoveListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -513,8 +532,8 @@
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
 		otherParent = ( ParentWithCollection ) s.get( otherParent.getClass(), otherParent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( Child ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		parent.removeChild( child );
 		otherParent.addChild( child );
@@ -524,8 +543,8 @@
 		if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		if ( ( ( PersistentCollection ) otherParent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), otherParent, index++ );
@@ -534,9 +553,9 @@
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherParent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherParent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -551,8 +570,8 @@
 		Transaction tx = s.beginTransaction();
 		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
 		otherParent = ( ParentWithCollection ) s.get( otherParent.getClass(), otherParent.getId() );
-		if ( child instanceof ChildEntity ) {
-			child = ( ChildEntity ) s.get( child.getClass(), ( ( ChildEntity ) child ).getId() );
+		if ( child instanceof Entity ) {
+			child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );
 		}
 		otherParent.addAllChildren( parent.getChildren() );
 		parent.clearChildren();
@@ -565,16 +584,16 @@
 		if ( ( ( PersistentCollection ) otherParent.getChildren() ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), otherParent, index++ );
 		}
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );
 		checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherParent, index++ );
 		checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherParent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}
@@ -598,24 +617,24 @@
 		if ( ( ( PersistentCollection ) otherCollectionOrig ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), otherParent, otherCollectionOrig, index++ );
 			otherChildOrig = ( Child ) otherCollectionOrig.iterator().next();
-			if ( otherChildOrig.hasBidirectionalManyToMany() ) {
-				checkResult( listeners, listeners.getInitializeCollectionListener(), otherChildOrig, index++ );
+			if ( otherChildOrig instanceof ChildWithBidirectionalManyToMany ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
 			}
 		}
 		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, otherParent.getChildren(), index++ );
 		Child otherChild = ( Child ) otherParent.getChildren().iterator().next();
-		if ( otherChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), otherChild, index++ );
+		if ( otherChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) otherChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, otherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, otherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), otherParent, otherCollectionOrig, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), otherParent, otherCollectionOrig, index++ );
-		if ( otherChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherChildOrig, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherChildOrig, index++ );
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherChild, index++ );
+		if ( otherChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), otherParent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), otherParent, index++ );
@@ -649,24 +668,24 @@
 		if ( ( ( PersistentCollection ) otherCollectionOrig ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), otherParent, otherCollectionOrig, index++ );
 			otherChildOrig = ( Child ) otherCollectionOrig.iterator().next();
-			if ( otherChildOrig.hasBidirectionalManyToMany() ) {
-				checkResult( listeners, listeners.getInitializeCollectionListener(), otherChildOrig, index++ );
+			if ( otherChildOrig instanceof ChildWithBidirectionalManyToMany ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
 			}
 		}
 		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, otherOtherParent.getChildren(), index++ );
 		Child otherOtherChild = ( Child ) otherOtherParent.getChildren().iterator().next();
-		if ( otherOtherChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), otherOtherChild, index++ );
+		if ( otherOtherChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) otherOtherChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, otherOtherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, otherOtherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), otherParent, otherCollectionOrig, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), otherParent, otherCollectionOrig, index++ );
-		if ( otherOtherChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherChildOrig, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherChildOrig, index++ );
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherOtherChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherOtherChild, index++ );
+		if ( otherOtherChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherChildOrig, index++ );
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherOtherChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherOtherChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), otherParent, otherOtherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), otherParent, otherOtherParent.getChildren(), index++ );
@@ -677,9 +696,9 @@
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), otherParent, otherOtherParent.getChildren(), index++ );
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), otherOtherParent, otherOtherCollectionOrig, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), otherOtherParent, otherOtherCollectionOrig, index++ );
-		if ( otherOtherChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), otherOtherChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), otherOtherChild, index++ );
+		if ( otherOtherChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherOtherChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) otherOtherChild, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), otherOtherParent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRecreateListener(), otherOtherParent, index++ );
@@ -721,11 +740,6 @@
 		return parent;
 	}
 
-	protected Collection getParents( Child child ) {
-		return ( ( child instanceof ChildWithBidirectionalManyToMany )
-						? ( ( ChildWithBidirectionalManyToMany ) child ).getParents()
-						: null );
-	}
 	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
 							 ParentWithCollection parent,
@@ -734,14 +748,14 @@
 	}
 	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
-							 Child child,
+							 ChildWithBidirectionalManyToMany child,
 							 int index) {
-		checkResult( listeners, listenerExpected, child, getParents( child ), index );
+		checkResult( listeners, listenerExpected, child, child.getParents(), index );
 	}
 
 	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
-							 Object ownerExpected,
+							 Entity ownerExpected,
 							 Collection collExpected,
 							 int index) {
 		assertSame( listenerExpected, listeners.getListenersCalled().get( index ) );
@@ -750,6 +764,10 @@
 				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwner()
 		);
 		assertSame(
+				ownerExpected.getId(),
+				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerId()
+		);
+		assertSame(
 				collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
 		);
 	}

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/BrokenCollectionEventTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/BrokenCollectionEventTest.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/BrokenCollectionEventTest.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -112,7 +112,7 @@
 	/*
 	public void testUpdateDetachedParentOneChildToNullFailureExpected() {
 		CollectionListeners listeners = new CollectionListeners( getSessions() );
-		AbstractParentWithCollection parent = createParentWithOneChild( "parent", "child" );
+		ParentWithCollection parent = createParentWithOneChild( "parent", "child" );
 		Child oldChild = ( Child ) parent.getChildren().iterator().next();
 		assertEquals( 1, parent.getChildren().size() );
 		listeners.clear();
@@ -126,9 +126,9 @@
 		int index = 0;
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( oldChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChild, index++ );
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) oldChild, index++ );
 		}
 		// pre- and post- collection recreate events should be created when updating an entity with a "null" collection
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
@@ -186,7 +186,7 @@
 	/*
 	public void testUpdateParentOneChildToNullFailureExpected() {
 		CollectionListeners listeners = new CollectionListeners( getSessions() );
-		AbstractParentWithCollection parent = createParentWithOneChild( "parent", "child" );
+		ParentWithCollection parent = createParentWithOneChild( "parent", "child" );
 		Child oldChild = ( Child ) parent.getChildren().iterator().next();
 		assertEquals( 1, parent.getChildren().size() );
 		listeners.clear();
@@ -204,14 +204,18 @@
 		if ( ( ( PersistentCollection ) oldCollection ).wasInitialized() ) {
 			checkResult( listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++ );
 		}
-		if ( oldChild.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( oldChild ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), oldChild, index++ );
+		ChildWithBidirectionalManyToMany oldChildWithManyToMany = null;
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			oldChildWithManyToMany = ( ChildWithBidirectionalManyToMany ) oldChild;
+			if ( ( ( PersistentCollection ) oldChildWithManyToMany.getParents() ).wasInitialized() ) {
+				checkResult( listeners, listeners.getInitializeCollectionListener(), oldChildWithManyToMany, index++ );
+			}
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( oldChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChild, index++ );
+		if ( oldChildWithManyToMany != null ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChildWithManyToMany, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChildWithManyToMany, index++ );
 		}
 		// pre- and post- collection recreate events should be created when updating an entity with a "null" collection
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
@@ -221,7 +225,7 @@
 
 	public void testUpdateMergedParentOneChildToNullFailureExpected() {
 		CollectionListeners listeners = new CollectionListeners( getSessions() );
-		AbstractParentWithCollection parent = createParentWithOneChild( "parent", "child" );
+		ParentWithCollection parent = createParentWithOneChild( "parent", "child" );
 		assertEquals( 1, parent.getChildren().size() );
 		listeners.clear();
 		Session s = openSession();
@@ -233,14 +237,18 @@
 		s.close();
 		int index = 0;
 		Child oldChild = ( Child ) oldCollection.iterator().next();
-		if ( oldChild.hasBidirectionalManyToMany() && ( ( PersistentCollection ) getParents( oldChild ) ).wasInitialized() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), oldChild, index++ );
+		ChildWithBidirectionalManyToMany oldChildWithManyToMany = null;
+		if ( oldChild instanceof ChildWithBidirectionalManyToMany ) {
+			oldChildWithManyToMany = ( ChildWithBidirectionalManyToMany ) oldChild;
+			if ( ( ( PersistentCollection ) oldChildWithManyToMany.getParents() ).wasInitialized() ) {
 		}
+			checkResult( listeners, listeners.getInitializeCollectionListener(), oldChildWithManyToMany, index++ );
+		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++ );
-		if ( oldChild.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChild, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChild, index++ );
+		if ( oldChildWithManyToMany != null ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), oldChildWithManyToMany, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), oldChildWithManyToMany, index++ );
 		}
 		// pre- and post- collection recreate events should be created when updating an entity with a "null" collection
 		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
@@ -282,27 +290,22 @@
 		return parent;
 	}
 
-	private Collection getParents( Child child ) {
-		return ( ( child instanceof ChildWithBidirectionalManyToMany )
-						? ( ( ChildWithBidirectionalManyToMany ) child ).getParents()
-						: null );
-	}
-	private void checkResult(CollectionListeners listeners,
+	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
 							 ParentWithCollection parent,
 							 int index) {
 		checkResult( listeners, listenerExpected, parent, parent.getChildren(), index );
 	}
-	private void checkResult(CollectionListeners listeners,
+	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
-							 Child child,
+							 ChildWithBidirectionalManyToMany child,
 							 int index) {
-		checkResult( listeners, listenerExpected, child, getParents( child ), index );
+		checkResult( listeners, listenerExpected, child, child.getParents(), index );
 	}
 
-	private void checkResult(CollectionListeners listeners,
+	protected void checkResult(CollectionListeners listeners,
 							 CollectionListeners.Listener listenerExpected,
-							 Object ownerExpected,
+							 Entity ownerExpected,
 							 Collection collExpected,
 							 int index) {
 		assertSame( listenerExpected, listeners.getListenersCalled().get( index ) );
@@ -311,6 +314,10 @@
 				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwner()
 		);
 		assertSame(
+				ownerExpected.getId(),
+				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerId()
+		);
+		assertSame(
 				collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
 		);
 	}

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Child.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Child.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Child.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -27,8 +27,6 @@
  */
 public interface Child {
 
-	boolean hasBidirectionalManyToMany();
-
 	String getName();
 
 	void setName(String name);

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildEntity.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildEntity.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildEntity.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -25,10 +25,9 @@
  *
  * @author Gail Badner
  */
-public class ChildEntity extends ChildValue {
+public class ChildEntity extends ChildValue implements Entity {
 	private Long id;
 
-
 	public ChildEntity() {
 		super();
 	}

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildValue.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildValue.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ChildValue.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -35,10 +35,6 @@
 		this.name = name;
 	}
 
-	public boolean hasBidirectionalManyToMany() {
-		return false;
-	}
-
 	public String getName() {
 		return name;
 	}

Added: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Entity.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Entity.java	                        (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/Entity.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -0,0 +1,14 @@
+package org.hibernate.test.event.collection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gbadner
+ * Date: Jan 30, 2008
+ * Time: 2:39:37 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface Entity {
+	Long getId();
+
+	void setId(Long id);
+}

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ParentWithCollection.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ParentWithCollection.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/ParentWithCollection.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -27,7 +27,7 @@
  *
  * @author Gail Badner
  */
-public interface ParentWithCollection {
+public interface ParentWithCollection extends Entity {
 	void newChildren(Collection collection);
 
 	Child createChild(String name);

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/AbstractAssociationCollectionEventTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/AbstractAssociationCollectionEventTest.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/AbstractAssociationCollectionEventTest.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -21,12 +21,13 @@
  */
 package org.hibernate.test.event.collection.association;
 
+import org.hibernate.Session;
+import org.hibernate.Transaction;
 import org.hibernate.test.event.collection.AbstractCollectionEventTest;
+import org.hibernate.test.event.collection.ChildEntity;
 import org.hibernate.test.event.collection.CollectionListeners;
-import org.hibernate.test.event.collection.ChildEntity;
 import org.hibernate.test.event.collection.ParentWithCollection;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import org.hibernate.test.event.collection.association.bidirectional.manytomany.ChildWithBidirectionalManyToMany;
 
 /**
  *
@@ -52,14 +53,14 @@
 		s.close();
 		int index = 0;
 		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getInitializeCollectionListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getInitializeCollectionListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ );
 		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, index++ );
-		if ( child.hasBidirectionalManyToMany() ) {
-			checkResult( listeners, listeners.getPreCollectionUpdateListener(), child, index++ );
-			checkResult( listeners, listeners.getPostCollectionUpdateListener(), child, index++ );
+		if ( child instanceof ChildWithBidirectionalManyToMany ) {
+			checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
+			checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );
 		}
 		checkNumberOfResults( listeners, index );
 	}

Modified: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/manytomany/ChildWithBidirectionalManyToMany.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/manytomany/ChildWithBidirectionalManyToMany.java	2008-01-30 22:55:47 UTC (rev 14301)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/manytomany/ChildWithBidirectionalManyToMany.java	2008-01-31 01:13:44 UTC (rev 14302)
@@ -40,10 +40,6 @@
 		this.parents = parents;
 	}
 
-	public boolean hasBidirectionalManyToMany() {
-		return true;
-	}
-
 	public Collection getParents() {
 		return parents;
 	}




More information about the hibernate-commits mailing list