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