Hey,
That wouldn't work for me. :-)
Sorry for the late reply. Was not in town.
Here are my hbm files.
Template1:
Code:
<class name="Template1" table="template1">
<id name="templateId" column="TEMPLATE_ID" type="java.lang.Integer" >
<generator class="native"/>
</id>
<property name="templateName" column="TEMPLATE_NAME" type="java.lang.String" not-null="true" />
<property name="lastUpdateTime" column="LAST_UPDATE_TIME" type="java.util.Date" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" not-null="true" />
<list name="templateElements" table="template_element" cascade="save-update,delete" inverse="true">
<key column="TEMPLATE_ID" not-null="true"/>
<index column="SEQUENCE" type="java.lang.Integer" />
<one-to-many class="TemplateElement"/>
</list>
<!-- I have also used set here. Still doesn't work. :-( -->
</class>
Element Param:
Code:
<class name="ElementParam" table="element_param">
<composite-id name="id" class="ElementParamKey">
<key-many-to-one name="templateElement" column="ELEMENT_ID" class="TemplateElement" />
<key-many-to-one name="parameter" column="PARAMETER_ID" class="Parameter" lazy="false"/>
</composite-id>
<property name="lastUpdateTime" column="LAST_UPDATE_TIME" type="java.util.Date" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" not-null="true" />
<property name="sequence" column="SEQUENCE" type="java.lang.Integer" />
</class>
Template Element:
Code:
<class name="TemplateElement" table="template_element">
<id name="elementId" column="ELEMENT_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="elementType" column="ELEMENT_TYPE" type="java.lang.String" not-null="true" />
<property name="elementName" column="ELEMENT_NAME" type="java.lang.String" not-null="true" />
<property name="lastUpdateTime" column="LAST_UPDATE_TIME" type="java.util.Date" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" not-null="true" />
<many-to-one name="templateElement" column="PARENT_ID" class="TemplateElement" cascade="save-update"/>
<many-to-one name="template1" column="TEMPLATE_ID" class="Template1" not-null="true"/>
<set name="childElementParams" table="element_param" cascade="save-update,persist,merge,delete" inverse="true">
<key column="ELEMENT_ID" not-null="true"/>
<one-to-many class="ElementParam" />
</set>
<!--<set name="childTemplateElements" table="element_param" cascade="save-update,delete" inverse="false">
<key column="PARENT_ID"/>
<one-to-many class="TemplateElement"/>
</set> -->
</class>
Parameter:
Code:
<class name="Parameter" table="parameter">
<id name="parameterId" column="PARAMETER_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="parameterName" column="PARAMETER_NAME" type="java.lang.String" not-null="true" />
<property name="parameterDescription" column="PARAMETER_DESCRIPTION" type="java.lang.String" />
<property name="parameterIndex" column="PARAMETER_INDEX" type="java.lang.String" />
<property name="clinicalType" column="CLINICAL_TYPE" type="java.lang.String" />
<property name="dataType" column="DATA_TYPE" type="java.lang.String" />
<property name="transferType" column="TRANSFER_TYPE" type="java.lang.String" />
<property name="unit" column="UNIT" type="java.lang.String" />
<property name="max" column="MAX" type="java.lang.Integer" />
<property name="min" column="MIN" type="java.lang.Integer" />
<property name="autoValidation" column="AUTO_VALIDATION" type="java.lang.Short" />
<property name="autoCopy" column="AUTO_COPY" type="java.lang.Short" />
<property name="lastUpdateTime" column="LAST_UPDATE_TIME" type="java.util.Date" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" />
<set name="parents" table="CATEGORY_PARAMETER">
<key column="PARAMETER_ID" />
<many-to-many column="CATEGORY_ID" class="Category"/>
</set>
<!--<use it when you need the parent TemplateElements using this Parameter>-->
<!--<set name="parentElements" table="element_param" cascade="save-update,persist">-->
<!--<key column="PARAMETER_ID" not-null="true"/>-->
<!--<many-to-many column="ELEMENT_ID" class="TemplateElement"/>-->
<!--</set>-->