-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Help Persisting Complex Collection of Inherited Types
PostPosted: Tue Jun 05, 2007 1:09 am 
Newbie

Joined: Tue Jun 05, 2007 12:57 am
Posts: 3
Ok, here goes my best at explaining the situation. Let's assume we have the following:

Code:
public interface A
{

}

public class B : A
{
}

public class C : A
{
}

public class Container
{
     public ISet<A> Members;
}


What would be the appropriate way to map the 'Container' class' Members set? The problem is that Members is *technically* homogenous, but in practice contains instances of B & C, which are different types (siblings in the inheritance tree from A)

I tried setting up a many-to-any that looked like this:
Code:
<set name="Members"
        table="container_members"
        cascade="all-delete-orphan">       
      <key column="parent_id"/>     
      <many-to-any id-type="guid" meta-type="string">
        <column name="member_type"/>
        <column name="member_id"/>       
      </many-to-any>
</set>   


but all I get is an exception stating that 'collection was not an association' which wasn't very helpful? Is there a better way of mapping this? joined-subclass' don't seem appropriate, particularly if B & C end up implementing other interfaces (it seems NHibernate won't let you declare the joined-subclass multiple times)

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.