Hi,
I am dealing with a legacy database where I need to map a many-to-one relation onto a table with a composite key.
The problem is that my composite key holds an empty string and a int equals to 0 for null values. When I load the many side table Hibernate tells me:
Code:
No row with the given identifier exists: ams.hibernate.BomPK@c48b77[bomId=,bomVer=0], of class: ams.hibernate.Bom; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: ams.hibernate.BomPK@c48b77[bomId=,bomVer=0], of class: ams.hibernate.Bom
Here is the many-to-one side mapping definition
Code:
<!-- bi-directional many-to-one association to Bom -->
<many-to-one
name="bom"
class="ams.hibernate.Bom"
not-null="true"
>
<column name="bom_id" />
<column name="bom_ver" />
</many-to-one>
Here is the one side mapping definition
Code:
<composite-id name="comp_id" class="ams.hibernate.BomPK">
<key-property
name="bomId"
column="bom_id"
type="java.lang.String"
length="15"
/>
<key-property
name="bomVer"
column="bom_ver"
type="java.lang.Integer"
length="4"
/>
</composite-id>
Any easy way to fix this ?