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

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Feb 6 02:46:52 EST 2008


Author: gbadner
Date: 2008-02-06 02:46:52 -0500 (Wed, 06 Feb 2008)
New Revision: 14313

Added:
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassCollectionEventTest.java
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassMapping.hbm.xml
   core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/ParentWithBidirectionalOneToManySubclass.java
Modified:
   core/branches/Branch_3_2/src/org/hibernate/action/CollectionRecreateAction.java
   core/branches/Branch_3_2/src/org/hibernate/action/CollectionRemoveAction.java
   core/branches/Branch_3_2/src/org/hibernate/action/CollectionUpdateAction.java
   core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/InitializeCollectionEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRecreateEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRemoveEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionUpdateEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRecreateEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRemoveEvent.java
   core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionUpdateEvent.java
   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
Log:
HHH-2616 :  added getter for owner entitity name to collection events


Modified: core/branches/Branch_3_2/src/org/hibernate/action/CollectionRecreateAction.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/action/CollectionRecreateAction.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/action/CollectionRecreateAction.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -57,7 +57,7 @@
 				.getPreCollectionRecreateEventListeners();
 		if (preListeners.length > 0) {
 			PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
-					getCollection(), ( EventSource ) getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession() );
 			for ( int i = 0; i < preListeners.length; i++ ) {
 				preListeners[i].onPreRecreateCollection( preEvent );
 			}
@@ -69,7 +69,7 @@
 				.getPostCollectionRecreateEventListeners();
 		if (postListeners.length > 0) {
 			PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
-					getCollection(), ( EventSource ) getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession() );
 			for ( int i = 0; i < postListeners.length; i++ ) {
 				postListeners[i].onPostRecreateCollection( postEvent );
 			}

Modified: core/branches/Branch_3_2/src/org/hibernate/action/CollectionRemoveAction.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/action/CollectionRemoveAction.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/action/CollectionRemoveAction.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -110,9 +110,7 @@
 				.getPreCollectionRemoveEventListeners();
 		if (preListeners.length>0) {
 			PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(
-					getCollection(),
-					affectedOwner,
-					( EventSource )getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
 			for ( int i = 0; i < preListeners.length; i++ ) {
 				preListeners[i].onPreRemoveCollection(preEvent);
 			}
@@ -124,9 +122,7 @@
 				.getPostCollectionRemoveEventListeners();
 		if (postListeners.length>0) {
 			PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
-					getCollection(),
-					affectedOwner,
-					( EventSource )getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
 			for ( int i = 0; i < postListeners.length; i++ ) {
 				postListeners[i].onPostRemoveCollection(postEvent);
 			}

Modified: core/branches/Branch_3_2/src/org/hibernate/action/CollectionUpdateAction.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/action/CollectionUpdateAction.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/action/CollectionUpdateAction.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -85,7 +85,7 @@
 				.getPreCollectionUpdateEventListeners();
 		if (preListeners.length > 0) {
 			PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
-					getCollection(), ( EventSource ) getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession() );
 			for ( int i = 0; i < preListeners.length; i++ ) {
 				preListeners[i].onPreUpdateCollection( preEvent );
 			}
@@ -97,7 +97,7 @@
 				.getPostCollectionUpdateEventListeners();
 		if (postListeners.length > 0) {
 			PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(
-					getCollection(), ( EventSource ) getSession() );
+					getPersister(), getCollection(), ( EventSource ) getSession() );
 			for ( int i = 0; i < postListeners.length; i++ ) {
 				postListeners[i].onPostUpdateCollection( postEvent );
 			}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/AbstractCollectionEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -4,7 +4,9 @@
 import java.io.Serializable;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.CollectionEntry;
 import org.hibernate.engine.EntityEntry;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * Defines a base class for events involving collections.
@@ -16,6 +18,7 @@
 	private final PersistentCollection collection;
 	private final Object affectedOwner;
 	private final Serializable affectedOwnerId;
+	private final String affectedOwnerEntityName;
 
 	/**
 	 * Constructs an AbstractCollectionEvent object.
@@ -28,16 +31,24 @@
 	 * by this event; can be null if unavailable
 	 * that is affected by this event; can be null if unavailable
 	 */
-	public AbstractCollectionEvent(PersistentCollection collection,
-								   EventSource source,
-								   Object affectedOwner,
-								   Serializable affectedOwnerId ) {
+	public AbstractCollectionEvent( CollectionPersister collectionPersister,
+					PersistentCollection collection,
+					EventSource source,
+					Object affectedOwner,
+					Serializable affectedOwnerId) {
 		super(source);
 		this.collection = collection;
 		this.affectedOwner = affectedOwner;
 		this.affectedOwnerId = affectedOwnerId;
+		this.affectedOwnerEntityName =
+				getAffectedOwnerEntityName( collectionPersister, affectedOwner, source );
 	}
 
+	protected static CollectionPersister getLoadedCollectionPersister( PersistentCollection collection, EventSource source ) {
+		CollectionEntry ce = source.getPersistenceContext().getCollectionEntry( collection );
+		return ( ce == null ? null : ce.getLoadedPersister() );		
+	}
+
 	protected static Object getLoadedOwnerOrNull( PersistentCollection collection, EventSource source ) {
 		return source.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
 	}
@@ -51,6 +62,21 @@
 		return ( ownerEntry == null ? null : ownerEntry.getId() );
 	}
 
+	protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source ) {
+
+		// collectionPersister should not be null, but we don't want to throw
+		// an exception if it is null
+		String entityName =
+				( collectionPersister == null ? null : collectionPersister.getOwnerEntityPersister().getEntityName() );
+		if ( affectedOwner != null ) {
+			EntityEntry ee = source.getPersistenceContext().getEntry( affectedOwner );
+			if ( ee != null && ee.getEntityName() != null) {
+				entityName = ee.getEntityName();
+			}
+		}	
+		return entityName;
+	}
+
 	public PersistentCollection getCollection() {
 		return collection;
 	}
@@ -75,4 +101,15 @@
 	public Serializable getAffectedOwnerIdOrNull() {
 		return affectedOwnerId;
 	}
+
+	/**
+	 * Get the entity name for the collection owner entity that is affected by this event.
+	 *
+	 * @return the entity name; if the owner is not in the PersistenceContext, the
+	 * returned value may be a superclass name, instead of the actual class name
+	 */
+	public String getAffectedOwnerEntityName() {
+		return affectedOwnerEntityName;
+	}
+
 }

Modified: core/branches/Branch_3_2/src/org/hibernate/event/InitializeCollectionEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/InitializeCollectionEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/InitializeCollectionEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -11,8 +11,10 @@
  */
 public class InitializeCollectionEvent extends AbstractCollectionEvent {
 
-	public InitializeCollectionEvent(PersistentCollection collection, EventSource source) {
-		super( collection, source,
+	public InitializeCollectionEvent(PersistentCollection collection, EventSource source ) {
+		super( getLoadedCollectionPersister( collection, source ),
+				collection,
+				source,
 				getLoadedOwnerOrNull( collection, source ),
 				getLoadedOwnerIdOrNull( collection, source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRecreateEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRecreateEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRecreateEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs after a collection is recreated
@@ -10,8 +11,10 @@
  */
 public class PostCollectionRecreateEvent extends AbstractCollectionEvent {
 
-	public PostCollectionRecreateEvent(PersistentCollection collection, EventSource source) {
-		super( collection, source,
+	public PostCollectionRecreateEvent( CollectionPersister collectionPersister,
+										PersistentCollection collection,
+										EventSource source ) {
+		super( collectionPersister, collection, source,
 				collection.getOwner(),
 				getOwnerIdOrNull( collection.getOwner(), source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRemoveEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRemoveEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionRemoveEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs after a collection is removed
@@ -10,8 +11,11 @@
  */
 public class PostCollectionRemoveEvent extends AbstractCollectionEvent {
 
-	public PostCollectionRemoveEvent(PersistentCollection collection, Object loadedOwner, EventSource source) {
-		super( collection, source,
+	public PostCollectionRemoveEvent(CollectionPersister collectionPersister,
+									 PersistentCollection collection,
+									 EventSource source,
+									 Object loadedOwner ) {
+		super( collectionPersister, collection, source,
 				loadedOwner,
 				getOwnerIdOrNull( loadedOwner, source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionUpdateEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionUpdateEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PostCollectionUpdateEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs after a collection is updated
@@ -10,8 +11,10 @@
  */
 public class PostCollectionUpdateEvent extends AbstractCollectionEvent {
 
-	public PostCollectionUpdateEvent(PersistentCollection collection, EventSource source) {
-		super( collection, source,
+	public PostCollectionUpdateEvent(CollectionPersister collectionPersister,
+									 PersistentCollection collection,
+									 EventSource source) {
+		super( collectionPersister, collection, source,
 				getLoadedOwnerOrNull( collection, source ),
 				getLoadedOwnerIdOrNull( collection, source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRecreateEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRecreateEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRecreateEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs before a collection is recreated
@@ -10,8 +11,10 @@
  */
 public class PreCollectionRecreateEvent extends AbstractCollectionEvent {
 
-	public PreCollectionRecreateEvent(PersistentCollection collection, EventSource source) {
-		super( collection, source,
+	public PreCollectionRecreateEvent(CollectionPersister collectionPersister,
+									  PersistentCollection collection,
+									  EventSource source) {
+		super( collectionPersister, collection, source,
 				collection.getOwner(),
 				getOwnerIdOrNull( collection.getOwner(), source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRemoveEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRemoveEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionRemoveEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs before a collection is removed
@@ -10,8 +11,11 @@
  */
 public class PreCollectionRemoveEvent extends AbstractCollectionEvent {
 
-	public PreCollectionRemoveEvent(PersistentCollection collection, Object loadedOwner, EventSource source) {
-		super( collection, source,
+	public PreCollectionRemoveEvent(CollectionPersister collectionPersister,
+									PersistentCollection collection,
+									EventSource source,
+									Object loadedOwner) {
+		super( collectionPersister, collection, source,
 				loadedOwner,
 				getOwnerIdOrNull( loadedOwner, source ) );
 	}

Modified: core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionUpdateEvent.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionUpdateEvent.java	2008-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/src/org/hibernate/event/PreCollectionUpdateEvent.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -2,6 +2,7 @@
 package org.hibernate.event;
 
 import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
 
 /**
  * An event that occurs before a collection is updated
@@ -10,8 +11,10 @@
  */
 public class PreCollectionUpdateEvent extends AbstractCollectionEvent {
 
-	public PreCollectionUpdateEvent(PersistentCollection collection, EventSource source) {
-		super( collection, source,
+	public PreCollectionUpdateEvent(CollectionPersister collectionPersister,
+									PersistentCollection collection,
+									EventSource source) {
+		super( collectionPersister, collection, source,
 				getLoadedOwnerOrNull( collection, source ),
 				getLoadedOwnerIdOrNull( collection, source ) );
 	}

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-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/AbstractCollectionEventTest.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -767,6 +767,10 @@
 				ownerExpected.getId(),
 				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
 		);
+		assertEquals(
+				ownerExpected.getClass().getName(),
+				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerEntityName()
+		);
 		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-02-05 23:55:35 UTC (rev 14312)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/BrokenCollectionEventTest.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -317,6 +317,10 @@
 				ownerExpected.getId(),
 				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
 		);
+		assertEquals(
+				ownerExpected.getClass().getName(),
+				( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerEntityName()
+		);
 		assertSame(
 				collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
 		);

Added: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassCollectionEventTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassCollectionEventTest.java	                        (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassCollectionEventTest.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -0,0 +1,57 @@
+//$Id: $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, 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.event.collection.association.bidirectional.onetomany;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Test;
+
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.event.collection.Child;
+import org.hibernate.test.event.collection.ParentWithCollection;
+import org.hibernate.test.event.collection.association.AbstractAssociationCollectionEventTest;
+import org.hibernate.test.event.collection.association.bidirectional.onetomany.ChildWithManyToOne;
+import org.hibernate.test.event.collection.association.bidirectional.onetomany.ParentWithBidirectionalOneToMany;
+
+/**
+ *
+ * @author Gail Badner
+ */
+public class BidirectionalOneToManyBagSubclassCollectionEventTest extends BidirectionalOneToManyBagCollectionEventTest {
+
+	public BidirectionalOneToManyBagSubclassCollectionEventTest(String string) {
+		super( string );
+	}
+
+	public static Test suite() {
+		return new FunctionalTestClassTestSuite( BidirectionalOneToManyBagSubclassCollectionEventTest.class );
+	}
+
+	public String[] getMappings() {
+		return new String[] { "event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassMapping.hbm.xml" };
+	}
+
+	public ParentWithCollection createParent(String name) {
+		return new ParentWithBidirectionalOneToManySubclass( name );
+	}
+}
\ No newline at end of file

Added: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassMapping.hbm.xml
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassMapping.hbm.xml	                        (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/BidirectionalOneToManyBagSubclassMapping.hbm.xml	2008-02-06 07:46:52 UTC (rev 14313)
@@ -0,0 +1,39 @@
+<?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.event.collection.association.bidirectional.onetomany">
+
+    <class name="ParentWithBidirectionalOneToMany" table="PARENT" discriminator-value="P">
+        <id name="id" column="ID" type="long">
+            <generator class="native"/>
+        </id>
+
+        <discriminator column="TYPE" type="string" length="1"/>
+
+        <bag name="children"
+             inverse="true"
+             cascade="all">
+            <key column="parent_id"/>
+            <one-to-many class="ChildWithManyToOne"/>
+        </bag>
+
+        <subclass name="ParentWithBidirectionalOneToManySubclass"
+            discriminator-value="S">
+        </subclass>
+    </class>
+
+    <class name="ChildWithManyToOne" table="CHILD">
+        <id name="id" column="ID" type="long">
+            <generator class="native"/>
+        </id>
+        <property name="name" column="NAME" type="string"/>
+        <many-to-one name="parent" column="parent_id" class="ParentWithBidirectionalOneToMany" cascade="none"/>
+    </class>
+
+</hibernate-mapping>

Added: core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/ParentWithBidirectionalOneToManySubclass.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/ParentWithBidirectionalOneToManySubclass.java	                        (rev 0)
+++ core/branches/Branch_3_2/test/org/hibernate/test/event/collection/association/bidirectional/onetomany/ParentWithBidirectionalOneToManySubclass.java	2008-02-06 07:46:52 UTC (rev 14313)
@@ -0,0 +1,42 @@
+//$Id: $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, 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.event.collection.association.bidirectional.onetomany;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.hibernate.test.event.collection.Child;
+import org.hibernate.test.event.collection.AbstractParentWithCollection;
+
+/**
+ *
+ * @author Gail Badner
+ */
+public class ParentWithBidirectionalOneToManySubclass extends ParentWithBidirectionalOneToMany {
+	public ParentWithBidirectionalOneToManySubclass() {
+	}
+
+	public ParentWithBidirectionalOneToManySubclass(String name) {
+		super( name );
+	}
+
+}
\ No newline at end of file




More information about the hibernate-commits mailing list