Hibernate version: 3.1
Due to some excellent help from a forum member I was able to define a class containing a subclass that contains a list of the class:
Code:
<class name="ActivityStep" lazy="true">
<id name="stepID">
<generator class="native"/>
</id>
<discriminator column="classID"/>
<property name="Type" not-null="true"/>
[b]...[/b]
<subclass name="ForStep">
<property name="InitialCondition" not-null="false"/>
<property name="EndCondition" not-null="false"/>
<property name="StepDelta" not-null="false"/>
<property name="Condition" column="ConditionValue" not-null="false"/>
<list name="Steps" cascade="all,delete-orphan">
<key column="stepID"/>
<index column="listIndex"/>
<many-to-many class="ActivityStep" column="stepchildID"/>
</list>
</subclass>
[b]...[/b]
</class>
and hibernate 'likes' this and I can create instances of Activitystep subclasses and their lists and save them into the database just fine.
The problem arises when I have another different class that wants to declare/use a list of Activitystep. My current definition is:
Code:
<class table="ACTIVITIES" name="Activities">
<id name="activityGroup">
<generator class="native"/>
</id>
<property name="Name" type="text" not-null="true"/>
[b]...[/b]
<list name="Steps" cascade="all,delete-orphan" >
<key column="activityGroup" not-null="true"/>
<list-index column="stepIndex"/>
<many-to-many class="ActivityStep" column="stepID" unique="true"/>
</list>
</class>
The list is supposed to be a list of steps, that may themselves contain a list of steps, that may also contain ...
At runtime, I get the following error:
Code:
WARN - SQL Error: 1364, SQLState: HY000
ERROR - Field 'stepchildID' doesn't have a default value
Is there a better or
proper way to define the Steps list to achieve my goal. Obviously I'm still a relative newbie at Hibernate.
Any help would be appreciated