mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 09:05:21 +00:00
HHH-2616 : added getter for owner entitity name to collection events
git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@14313 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
914e233f90
commit
83f06c38ba
@ -57,7 +57,7 @@ private void preRecreate() {
|
|||||||
.getPreCollectionRecreateEventListeners();
|
.getPreCollectionRecreateEventListeners();
|
||||||
if (preListeners.length > 0) {
|
if (preListeners.length > 0) {
|
||||||
PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
|
PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
|
||||||
getCollection(), ( EventSource ) getSession() );
|
getPersister(), getCollection(), ( EventSource ) getSession() );
|
||||||
for ( int i = 0; i < preListeners.length; i++ ) {
|
for ( int i = 0; i < preListeners.length; i++ ) {
|
||||||
preListeners[i].onPreRecreateCollection( preEvent );
|
preListeners[i].onPreRecreateCollection( preEvent );
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ private void postRecreate() {
|
|||||||
.getPostCollectionRecreateEventListeners();
|
.getPostCollectionRecreateEventListeners();
|
||||||
if (postListeners.length > 0) {
|
if (postListeners.length > 0) {
|
||||||
PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
|
PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
|
||||||
getCollection(), ( EventSource ) getSession() );
|
getPersister(), getCollection(), ( EventSource ) getSession() );
|
||||||
for ( int i = 0; i < postListeners.length; i++ ) {
|
for ( int i = 0; i < postListeners.length; i++ ) {
|
||||||
postListeners[i].onPostRecreateCollection( postEvent );
|
postListeners[i].onPostRecreateCollection( postEvent );
|
||||||
}
|
}
|
||||||
|
@ -110,9 +110,7 @@ private void preRemove() {
|
|||||||
.getPreCollectionRemoveEventListeners();
|
.getPreCollectionRemoveEventListeners();
|
||||||
if (preListeners.length>0) {
|
if (preListeners.length>0) {
|
||||||
PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(
|
PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(
|
||||||
getCollection(),
|
getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
|
||||||
affectedOwner,
|
|
||||||
( EventSource )getSession() );
|
|
||||||
for ( int i = 0; i < preListeners.length; i++ ) {
|
for ( int i = 0; i < preListeners.length; i++ ) {
|
||||||
preListeners[i].onPreRemoveCollection(preEvent);
|
preListeners[i].onPreRemoveCollection(preEvent);
|
||||||
}
|
}
|
||||||
@ -124,9 +122,7 @@ private void postRemove() {
|
|||||||
.getPostCollectionRemoveEventListeners();
|
.getPostCollectionRemoveEventListeners();
|
||||||
if (postListeners.length>0) {
|
if (postListeners.length>0) {
|
||||||
PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
|
PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
|
||||||
getCollection(),
|
getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
|
||||||
affectedOwner,
|
|
||||||
( EventSource )getSession() );
|
|
||||||
for ( int i = 0; i < postListeners.length; i++ ) {
|
for ( int i = 0; i < postListeners.length; i++ ) {
|
||||||
postListeners[i].onPostRemoveCollection(postEvent);
|
postListeners[i].onPostRemoveCollection(postEvent);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ private void preUpdate() {
|
|||||||
.getPreCollectionUpdateEventListeners();
|
.getPreCollectionUpdateEventListeners();
|
||||||
if (preListeners.length > 0) {
|
if (preListeners.length > 0) {
|
||||||
PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
|
PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
|
||||||
getCollection(), ( EventSource ) getSession() );
|
getPersister(), getCollection(), ( EventSource ) getSession() );
|
||||||
for ( int i = 0; i < preListeners.length; i++ ) {
|
for ( int i = 0; i < preListeners.length; i++ ) {
|
||||||
preListeners[i].onPreUpdateCollection( preEvent );
|
preListeners[i].onPreUpdateCollection( preEvent );
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ private void postUpdate() {
|
|||||||
.getPostCollectionUpdateEventListeners();
|
.getPostCollectionUpdateEventListeners();
|
||||||
if (postListeners.length > 0) {
|
if (postListeners.length > 0) {
|
||||||
PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(
|
PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(
|
||||||
getCollection(), ( EventSource ) getSession() );
|
getPersister(), getCollection(), ( EventSource ) getSession() );
|
||||||
for ( int i = 0; i < postListeners.length; i++ ) {
|
for ( int i = 0; i < postListeners.length; i++ ) {
|
||||||
postListeners[i].onPostUpdateCollection( postEvent );
|
postListeners[i].onPostUpdateCollection( postEvent );
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.engine.CollectionEntry;
|
||||||
import org.hibernate.engine.EntityEntry;
|
import org.hibernate.engine.EntityEntry;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a base class for events involving collections.
|
* Defines a base class for events involving collections.
|
||||||
@ -16,6 +18,7 @@ public abstract class AbstractCollectionEvent extends AbstractEvent {
|
|||||||
private final PersistentCollection collection;
|
private final PersistentCollection collection;
|
||||||
private final Object affectedOwner;
|
private final Object affectedOwner;
|
||||||
private final Serializable affectedOwnerId;
|
private final Serializable affectedOwnerId;
|
||||||
|
private final String affectedOwnerEntityName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an AbstractCollectionEvent object.
|
* Constructs an AbstractCollectionEvent object.
|
||||||
@ -28,14 +31,22 @@ public abstract class AbstractCollectionEvent extends AbstractEvent {
|
|||||||
* by this event; can be null if unavailable
|
* by this event; can be null if unavailable
|
||||||
* that is affected by this event; can be null if unavailable
|
* that is affected by this event; can be null if unavailable
|
||||||
*/
|
*/
|
||||||
public AbstractCollectionEvent(PersistentCollection collection,
|
public AbstractCollectionEvent( CollectionPersister collectionPersister,
|
||||||
EventSource source,
|
PersistentCollection collection,
|
||||||
Object affectedOwner,
|
EventSource source,
|
||||||
Serializable affectedOwnerId ) {
|
Object affectedOwner,
|
||||||
|
Serializable affectedOwnerId) {
|
||||||
super(source);
|
super(source);
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
this.affectedOwner = affectedOwner;
|
this.affectedOwner = affectedOwner;
|
||||||
this.affectedOwnerId = affectedOwnerId;
|
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 ) {
|
protected static Object getLoadedOwnerOrNull( PersistentCollection collection, EventSource source ) {
|
||||||
@ -51,6 +62,21 @@ protected static Serializable getOwnerIdOrNull( Object owner, EventSource source
|
|||||||
return ( ownerEntry == null ? null : ownerEntry.getId() );
|
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() {
|
public PersistentCollection getCollection() {
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
@ -75,4 +101,15 @@ public Object getAffectedOwnerOrNull() {
|
|||||||
public Serializable getAffectedOwnerIdOrNull() {
|
public Serializable getAffectedOwnerIdOrNull() {
|
||||||
return affectedOwnerId;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
public class InitializeCollectionEvent extends AbstractCollectionEvent {
|
public class InitializeCollectionEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public InitializeCollectionEvent(PersistentCollection collection, EventSource source) {
|
public InitializeCollectionEvent(PersistentCollection collection, EventSource source ) {
|
||||||
super( collection, source,
|
super( getLoadedCollectionPersister( collection, source ),
|
||||||
|
collection,
|
||||||
|
source,
|
||||||
getLoadedOwnerOrNull( collection, source ),
|
getLoadedOwnerOrNull( collection, source ),
|
||||||
getLoadedOwnerIdOrNull( collection, source ) );
|
getLoadedOwnerIdOrNull( collection, source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs after a collection is recreated
|
* An event that occurs after a collection is recreated
|
||||||
@ -10,8 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
public class PostCollectionRecreateEvent extends AbstractCollectionEvent {
|
public class PostCollectionRecreateEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PostCollectionRecreateEvent(PersistentCollection collection, EventSource source) {
|
public PostCollectionRecreateEvent( CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source ) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
collection.getOwner(),
|
collection.getOwner(),
|
||||||
getOwnerIdOrNull( collection.getOwner(), source ) );
|
getOwnerIdOrNull( collection.getOwner(), source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs after a collection is removed
|
* An event that occurs after a collection is removed
|
||||||
@ -10,8 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
public class PostCollectionRemoveEvent extends AbstractCollectionEvent {
|
public class PostCollectionRemoveEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PostCollectionRemoveEvent(PersistentCollection collection, Object loadedOwner, EventSource source) {
|
public PostCollectionRemoveEvent(CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source,
|
||||||
|
Object loadedOwner ) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
loadedOwner,
|
loadedOwner,
|
||||||
getOwnerIdOrNull( loadedOwner, source ) );
|
getOwnerIdOrNull( loadedOwner, source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs after a collection is updated
|
* An event that occurs after a collection is updated
|
||||||
@ -10,8 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
public class PostCollectionUpdateEvent extends AbstractCollectionEvent {
|
public class PostCollectionUpdateEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PostCollectionUpdateEvent(PersistentCollection collection, EventSource source) {
|
public PostCollectionUpdateEvent(CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
getLoadedOwnerOrNull( collection, source ),
|
getLoadedOwnerOrNull( collection, source ),
|
||||||
getLoadedOwnerIdOrNull( collection, source ) );
|
getLoadedOwnerIdOrNull( collection, source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs before a collection is recreated
|
* An event that occurs before a collection is recreated
|
||||||
@ -10,8 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
public class PreCollectionRecreateEvent extends AbstractCollectionEvent {
|
public class PreCollectionRecreateEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PreCollectionRecreateEvent(PersistentCollection collection, EventSource source) {
|
public PreCollectionRecreateEvent(CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
collection.getOwner(),
|
collection.getOwner(),
|
||||||
getOwnerIdOrNull( collection.getOwner(), source ) );
|
getOwnerIdOrNull( collection.getOwner(), source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs before a collection is removed
|
* An event that occurs before a collection is removed
|
||||||
@ -10,8 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
public class PreCollectionRemoveEvent extends AbstractCollectionEvent {
|
public class PreCollectionRemoveEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PreCollectionRemoveEvent(PersistentCollection collection, Object loadedOwner, EventSource source) {
|
public PreCollectionRemoveEvent(CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source,
|
||||||
|
Object loadedOwner) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
loadedOwner,
|
loadedOwner,
|
||||||
getOwnerIdOrNull( loadedOwner, source ) );
|
getOwnerIdOrNull( loadedOwner, source ) );
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.hibernate.event;
|
package org.hibernate.event;
|
||||||
|
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event that occurs before a collection is updated
|
* An event that occurs before a collection is updated
|
||||||
@ -10,8 +11,10 @@
|
|||||||
*/
|
*/
|
||||||
public class PreCollectionUpdateEvent extends AbstractCollectionEvent {
|
public class PreCollectionUpdateEvent extends AbstractCollectionEvent {
|
||||||
|
|
||||||
public PreCollectionUpdateEvent(PersistentCollection collection, EventSource source) {
|
public PreCollectionUpdateEvent(CollectionPersister collectionPersister,
|
||||||
super( collection, source,
|
PersistentCollection collection,
|
||||||
|
EventSource source) {
|
||||||
|
super( collectionPersister, collection, source,
|
||||||
getLoadedOwnerOrNull( collection, source ),
|
getLoadedOwnerOrNull( collection, source ),
|
||||||
getLoadedOwnerIdOrNull( collection, source ) );
|
getLoadedOwnerIdOrNull( collection, source ) );
|
||||||
}
|
}
|
||||||
|
@ -767,6 +767,10 @@ protected void checkResult(CollectionListeners listeners,
|
|||||||
ownerExpected.getId(),
|
ownerExpected.getId(),
|
||||||
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
|
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
|
||||||
);
|
);
|
||||||
|
assertEquals(
|
||||||
|
ownerExpected.getClass().getName(),
|
||||||
|
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerEntityName()
|
||||||
|
);
|
||||||
assertSame(
|
assertSame(
|
||||||
collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
|
collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
|
||||||
);
|
);
|
||||||
|
@ -317,6 +317,10 @@ protected void checkResult(CollectionListeners listeners,
|
|||||||
ownerExpected.getId(),
|
ownerExpected.getId(),
|
||||||
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
|
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerIdOrNull()
|
||||||
);
|
);
|
||||||
|
assertEquals(
|
||||||
|
ownerExpected.getClass().getName(),
|
||||||
|
( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getAffectedOwnerEntityName()
|
||||||
|
);
|
||||||
assertSame(
|
assertSame(
|
||||||
collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
|
collExpected, ( ( AbstractCollectionEvent ) listeners.getEvents().get( index ) ).getCollection()
|
||||||
);
|
);
|
||||||
|
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
@ -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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user