-->
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: Another Parent/Child Tree Question
PostPosted: Wed Jan 16, 2008 9:30 pm 
Newbie

Joined: Mon Jan 07, 2008 3:38 pm
Posts: 1
Hibernate version:
1.2

Name and version of the database you are using:
MSSQL2005

Hello,
First, I apologize for my ignorance. I'm wondering if someone can point me in the right direction. I've RTFM and done some searches on here, but still haven't been able to find what I'm looking for. I have the following:
Goal
SubGoal:Goal

I'm trying to create the mapping document such that, the root of the tree is a PrimaryGoal that contains a collection of SubGoals. The catch is, a Goal can also be a SubGoal. I tried using a discriminator but it blew up when a primary goal was listed as a sub goal.
Code:
PrimaryGoal
       | - SubGoal
       | - SubGoal
                |- PrimaryGoal


Here is my mapping file. Again, I'm new so bear with me:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" assembly="AssemblyName" namespace="NameSpace">
<class name="Goal" table="Goals" discriminator-value="True">
     <id name="Id" column="GoalId" type="Int32" unsaved-value="0">
         <generator class="identity" />
     </id>

     <discriminator column="IsPrimary" />
      
     <property name="Name" column="GoalName" type="string" />
      
     <idbag table="GoalRelationships" name="SubGoals">
       <collection-id column="GoalRelationshipId" type="int" >
       <generator class="identity" />
       </collection-id>
       <key column="ParentGoalId" />
       <many-to-many class="SubGoal" column="SubGoalId" fetch="join" />
     </idbag>

     <joined-subclass name="SubGoal" table="SubGoals">
        <key column="SubGoalId" />
        </joined-subclass>
    </class>
</hibernate-mapping>


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 9:42 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
I believe your mapping should be simpler, more in the line of this

http://lykke.wordpress.com/2006/08/04/s ... hibernate/

_________________
Gonzalo Díaz


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.