-->
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: How to map maps with entities as values?
PostPosted: Sat Feb 07, 2004 3:52 pm 
Newbie

Joined: Sun Jan 25, 2004 2:35 pm
Posts: 5
Hello,

can you give me a short example on how to map a one-to-many relationship between two classes. The "many" classes are stored in a map in the "one" class and therefore I don't know how to map this. The two classes:

Code:
public class Parent {

   private Map childs = new HashMap();
   private int id;

   ...

   public void setChilds(Map childs) {
 

      this.childs = childs;
   }

   public Map getChilds() {

      return this.childs;
   }
}


Code:
public class Child {

   private String name;
   private int id;

   ...

}


I want to use the name of each child as key for the map and the object itself as value. I'd only seen examples which using not objects as elemnts. I'am using one table per class.

Thank you.

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2004 4:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<map ....>
  <key ..../>
  <index .../>
  <one-to-many ...>
</map>


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.