Hibernate version: 3.1
Name and version of the database you are using: MySQL 4.1.12a-nt
Hello,
I have a little problem with an association :
- I have an object Profile and an object Method.
- A Profile contains many methods.
- A profile contains a default method.
- A method have a sub-classe : MethodSubclasse
Here is my mapping file :
Code:
<!-- ********************************************************************
CONFIDENTIALITY_PROFILE TABLE
********************************************************************** -->
<class name="ConfidentialityProfile" table="confidentiality_profile">
<id name="id" type="long">
<generator class="identity"/>
</id>
<property name="name"/>
<property name="description"/>
<property name="startValidity" column="start_validity"/>
<property name="endValidity" column="end_validity"/>
<set name="confidentialityMethods" cascade="all,delete-orphan">
<key column="confidentiality_profile_id" />
<one-to-many class="ConfidentialityMethod"/>
</set>
<many-to-one name="systemUser" class="SystemUser" column="system_user_id" not-null="true"/>
<!-- <many-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" column="default_confidentiality_method_id" unique="true" not-null="true" /> -->
<one-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" constrained="true" />
</class>
<!-- ********************************************************************
CONFIDENTIALITY_METHOD TABLE
********************************************************************** -->
<class name="ConfidentialityMethod" table="confidentiality_method">
<id name="id" type="long">
<generator class="identity"/>
</id>
<property name="name"/>
<property name="description"/>
<property name="startValidity" column="start_validity"/>
<property name="endValidity" column="end_validity"/>
<property name="status"/>
<property name="statusComment" column="status_comment"/>
<property name="statusDate" column="status_date"/>
<map name="attributes" table="confidentiality_method_attributes">
<key column="id"/>
<map-key column="attribute_name" type="string"/>
<element column="attribute_value" type="serializable" not-null="true"/>
</map>
<many-to-one name="confidentialityProfile" class="ConfidentialityProfile" column="confidentiality_profile_id" not-null="true"/>
<!-- ********************************************************************
CONFIDENTIALITY_METHOD_SUBCLASS TABLE
********************************************************************** -->
<joined-subclass name="ConfidentialityMethodSubclass" table="confidentiality_method_subclass">
<key column="id"/>
</joined-subclass>
</class>
If I'm using this in the Profile object :
Code:
<many-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" column="default_confidentiality_method_id" unique="true" not-null="true" />
When I change the default method, it works but when I do getDefaultMethod, it return a Method object and not a DefaultSubclass object...
If I'm using :
Code:
<one-to-one name="defaultConfidentialityMethod" class="ConfidentialityMethod" constrained="true" />
I receive the good object (MethodSubclass) but when I change the default method, the DB is not updated...
I don't know where is the problem...
Thank you...