When defining a composite ID using hbm.xml, if I define the "class" attribute of the "composite-id" node for a class, the properties are not populated with the values retrieved from the database when a collection of entities are returned.
Code:
...
<class name="com.acme.orders.entity.CustomerInventory" table="CUSTINVENTORY">
<composite-id class="com.acme.orders.entity.CustomerInventoryPK">
<key-property name="custId" type="integer" column="CUSTOMERID" access="field"/>
<key-property name="id" type="java.lang.Long" column="ID" access="field"/>
</composite-id>
<version name="version" access="field" column="VERSION" type="integer"/>
<property name="quantity" type="integer" column="QUANTITY" access="field"/>
...
The config above causes a CustomerInventory object to have 0 and NULL values for the custId and id respectively
Code:
customerInventory.id == null;
customerInventory.custId == 0;
If I do not define the class name for the composite ID, the properties are populated with the correct values retrieved from the database;
Code:
...
<class name="com.acme.orders.entity.CustomerInventory" table="CUSTINVENTORY">
<composite-id>
<key-property name="custId" type="integer" column="CUSTOMERID" access="field"/>
<key-property name="id" type="java.lang.Long" column="ID" access="field"/>
</composite-id>
<version name="version" access="field" column="VERSION" type="integer"/>
<property name="quantity" type="integer" column="QUANTITY" access="field"/>
...
The above config populates a CustomerInventory object correctly;
Code:
customerInventory.id == 27;
customerInventory.custId == 1;
Is there a setting or something missing from my hbm.xml config that causes this behaviour? I need to be able to define the composite id class for other aspects of the application to function correctly.
Thanks
John