Strange behaviour with Set and Composite Key
I see that in parent/child relationship where parent key is composite if I change on child the key order a wrong query is generated (verified by SQL Profiler - P6SPY) and my application throws error!
Code snippet:
PARENT
Code:
<class
name="ParentXXXX"
table="PARENT"
>
.......
.......
<composite-id name="pk" class="ParentXXXX_PK">
<key-property
name="fkFunctionId"
column="FK_FUNCTION_ID"
type="long"
length="22"
/>
<key-property
name="fkRoleId"
column="FK_ROLE_ID"
type="long"
length="22"
/>
</composite-id>
......
......
<set name="constraints" lazy="false" inverse="true" cascade="save-update">
<key>
<column name="FK_FA_FUNCTION_ID" />
<column name="FK_FA_ROLE_ID" />
</key>
<one-to-many class="ChildXXXX" />
</set>
CHILD (wrong code: exchange VALUE of FK_FA_ROLE_ID and FK_FA_FUNCTION_ID on SELECT)
Code:
<class
name="ChildXXXX"
table="CHILD"
>
.......
.......
<many-to-one
name="parent"
class="ParentXXXX"
>
<column name="FK_FA_ROLE_ID" />
<column name="FK_FA_FUNCTION_ID" />
</many-to-one>
CHILD (it's OK)
Code:
<many-to-one
name="parent"
class="ParentXXXX"
>
<column name="FK_FA_FUNCTION_ID" />
<column name="FK_FA_ROLE_ID" />
</many-to-one>
Is this behaviour correct??????