Code:
Tables
-----------------------------------------
|-------------------|
| Organization |
| -orgID |
| -name |
|-------------------|
|-------------------|
| OrgChildren_RT|
| -parent_fk |
| -child_fk |
|-------------------|
Object Model
-----------------------------------
public class OrganizationDTO {
private Integer orgID;
private Collection children; //Collection of OrganizationDTO's
private OrganizationDTO parent;
}
I can get the children (One-To-Many) mapping to work just fine. I want to create a mapping to the parent field in OrganizationDTO using the above table model. Any thoughts on how to approach this?
Thanks in advance.
Hibernate version: 3.2
Mapping documents:Code:
<hibernate-mapping>
<class name="OrganizationDTO" table="organization">
<id name="orgID" column="orgID">
<generator class="native"/>
</id>
<property name="name"/>
<set name="children" table="children_rt" inverse="false">
<key column="org_fk"/>
<many-to-many column="child_fk" class="OrganizationDTO"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Code:
dao.createOrg(child);
dao.createOrg(parent);
child.setParent(parent);
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL 4.X
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: