-->
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: Advanced Mapping Question
PostPosted: Thu Jan 11, 2007 4:07 pm 
Newbie

Joined: Fri Dec 29, 2006 1:06 pm
Posts: 3
Location: US
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:


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.