-->
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: General Mapping for Nested Composites: Best Approach
PostPosted: Mon May 19, 2008 3:49 am 
Newbie

Joined: Mon May 19, 2008 3:31 am
Posts: 1
Location: USA
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2

Mapping documents:none so far

Code between sessionFactory.openSession() and session.close():none so far

Full stack trace of any exception that occurs:n/a

Name and version of the database you are using:mySQL 5.0

The generated SQL (show_sql=true):none

Debug level Hibernate log excerpt:n/a


Problems with Session and transaction handling? No

Read this: http://hibernate.org/42.html

Hi All,
I've searched the FAQs and tutorials, and I can't find an answer to what I think is a simple mapping: multiple nested composites. For example, how do I map the following classes? A machine instance has a Set of control panels, each of which has a Set of controls. Machine is an entity, and ControlPanel and Control are value types. What if Machine had more than one such collection? What is the general mapping pattern for X is composed of a set of Y's, and Y is composed of a set of Zs (ad infinitum)?

==========================

Code:
public class Machine {
   private Set controlPanels;
   private long id;
   private String name;
   
   public Set getControlPanels() {return controlPanels;}
   public void setControlPanels(Set controlPanels) {this.controlPanels = controlPanels;}
   public long getId() {return id;}
   public void setId(long id) {this.id = id;}
   public String getName() {return name;}
   public void setName(String name) {this.name = name;}
}

public class ControlPanel {
   private Set controls;
   private long id;
   private String name;
   
   public Set getControls() {return controls;}
   public void setControls(Set controls) {this.controls = controls;}
   public long getId() {return id;}
   public void setId(long id) {this.id = id;}
   public String getName() {return name;}
   public void setName(String name) {this.name = name;}
}

public class Control {
   private long id;
   private String name;
   
   public long getId() {return id;}
   public void setId(long id) {this.id = id;}
   public String getName() {return name;}
   public void setName(String name) {this.name = name;}
}

==========================

Thanks for all assistance. Meanwhile, I'll keep looking and experimenting. (Yes, I have Hibernate in Action!)

_________________
Jason Morris
Morris Technical Solutions LLC


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.