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!)