All,
I have two sorts of relationships being maintained in an association table, and I've been banging my head against trying to figure out how to map them.
What I have is a form type and an application type as below.:
Code:
public class Form{
private long _id;
private long _name;
/*Accessors*/
}
Code:
public class Application{
private long _id;
private String _name;
private List _mandatoryForms;
private List _optionalForms;
/*Accessors*/
}
An application can have any number of optional forms or mandatory forms. The relationship between objects of these two types is maintained in a single table (TPACKAGES) with the following columns:
- pid - A primary key
- application_id - The primary key for the application
- form_id - The primary key for the form
- ordernum - The order the form should appear in the List
- required - 1 if the form should be mandatory 0 if it should be optional
Testing with just a single list of forms (ignoring the required column) it all worked with this mapping:
Code:
<hibernate-mapping package="eg">
<class name="Application" table="tapplication">
<id name="id" column="appid" type="long">
<generator class="sequence">
<param name="sequence">APPIDSEQ</param>
</generator>
</id>
<property name="name" column="appname" type="string"/>
<list name="MandatoryForms" lazy="false" table="tpackages">
<key column="application_id"/>
<index column="ordernum"/>
<many-to-many class="Form" column="form_id"/>
</list>
</class>
</hibernate-mapping>
So, my question: Is there any way to modify the list mapping to include the specification of a value for the required column? I know I can use the "where" attribute to retrieve configured objects, but is there any way I can ensure that the requried attribute is correctly specified for .save'd application objects?
Thanks much,
- Court