-->
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.  [ 2 posts ] 
Author Message
 Post subject: one-to-many for inversed any relationship
PostPosted: Wed Aug 29, 2007 8:57 am 
Newbie

Joined: Wed Aug 29, 2007 8:43 am
Posts: 5
Location: Philahttps://forum.hibernate.org/ucp.php?i=profile&mode=reg_detailsdelphia, PA
Thanks for any help! Assume I have three classes:

Code:
public class ParentClassAImpl implements ParentInterface {

  private Set<ChildClass> childClasses = new HashSet<ChildClass>();
 
}

public class ParentClassBImpl implements ParentInterface {

  private Set<ChildClass> childClasses = new HashSet<ChildClass>();

}

public class ChildClass {

  private ParentInterface parentInterface;

}


Assume a child can have an association to either ParentClassA or ParentClassB. In the ChildClass.hbm.xml, I would map this with the <any> relationship:

Code:
<any name="parentInterface" meta-type="string" id-type="string">
  <meta-value value="A" class="ParentClassAImpl"/>
  <meta-value value="B" class="ParentClassBImpl"/>
  <column name="entity_type"/>
  <column name="entity_id"/>
</any>


However, how do I map a one-to-many Set<ChildClass> in ParentClassAImpl.hbm.xml and ParentClassBImpl.xml? I basically want ParentClassAImpl.childClasses = all ChildClasses where entity_type = A and entity_id = ParentClassAImpl.id

I do not see how to express this in a mapping file given that the format for a set only allows you to specify a key column.

In summary: I can map a child class to have an <any> relationship back to a parent, but how do I map the set of children for a particular parent?

Thanks so much for any help!

Arthur Loder
Software Engineer
Comcast Interactive Media


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 2:32 pm 
Newbie

Joined: Wed Aug 29, 2007 8:43 am
Posts: 5
Location: Philahttps://forum.hibernate.org/ucp.php?i=profile&mode=reg_detailsdelphia, PA
I don't like replying to my own post, but since no one has responded and it's been almost a month, I figured I'd try again. Any thoughts?


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

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.