Hi all,
I am running into a problem when using a composite key on a couple of tables.
First off, I have a "Container" object that has the following in its definition:
......
<class name="Ryder.Arsenal.LLM.LPS.Container, Ryder.Arsenal.LLM" table="Lps_Container">
<composite-id>
<key-many-to-one name="Account" column="AcctOrg" />
<key-property name="ContainerId" column="ContainerId" type="string" length="32" />
</composite-id>
<property name="Description" column="Descr" />
<property name="Category" column="Category" />
......
the container class is implementing "serializable" and is also overriding both Equals and GetHashCode
now, I have a "Packaging" object that
......
<many-to-one name="Container" insert="false" update="false" cascade="none" class="Ryder.Arsenal.LLM.LPS.Container, Ryder.Arsenal.LLM">
<column name="AcctOrg" />
<column name="ContainerId" />
</many-to-one>
......
Each packaging object refers to a row in a packaging table. The problem I am running into is this:
AcctOrg will always be populated in a package row, but ContainerId might not be because the package might not have a container associated with it. If I do have a containerId setup, this works fine, but when ContainerId is null I am getting an exception saying "No row with the given identifier exists", which I understand why, but what I want to happen is it just ignores it and goes on its merry way.
So, is there a way to set this up (either in the XML or in the overridden methods) so that it recognizes that when ContainerId is null that there is no container to fetch for it? Is there a way to make it setup the composite key to be null if one of those properties of the key is null?
Thanks in advance!!!
|