I have a table structure like so:
Code:
Order{
- orderid
- Set orderitems
- ...
}
with: <set
name="orderItems"
lazy="true"
inverse="true"
> ...
-------------------------------
OrderItem{
- orderitemid
- Set orderitems
- ...
}
with: <many-to-one
name="item"
class="Item"
not-null="false"
>
<column name="SKU"/>
</many-to-one>
-------------------------
Item{
- sku (PK)
- Set orderitems
- ...
}
with: <id
name="sku"
type="java.lang.String"
column="SKU"
>
<generator class="assigned"/>
</id>
When accessing the orderitems collection I get this:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection Caused by: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: ABC123
I have read the documentation and tried 'foreign-key' etc without any success. How can I make it 'ok' for the object to not to exist in the Item table? Or do I have to change it back to just using a String reference to SKU and then do a lookup on the ItemDao for the actually object.