Hibernate 2.1.1
Oracle 8.1.6
Here is my snippets.
mapping document:
Code:
<many-to-one
name="cargo"
class="eg.CodeCargo">
<column name="CARGO"/>
</many-to-one>
<many-to-one
name="cargoWaggon"
class="eg.CargoWaggon"
>
<column name="NUM_TRAIN" />
<column name="WAG_NUM" />
<column name="DATE_INP" />
</many-to-one>
...
Everithing works fine, until one of composite-id column is NULL
then UnresolvableObjectException occurs
here is part of stack trace:
Code:
2004-05-27 09:24:36,408 ERROR [STDERR] net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: com.azovstal.ugdt.hibernate.CargoWaggonPK@10704e1[numTrain=<null>,numWaggon=108,dateInp=<null>], of class: com.azovstal.ugdt.hibernate.CargoWaggon
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1881)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2132)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:109)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3440)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:177)
almost the same occurs, if eg.CodeCargo has value which is absent in referenced table
Code:
2004-05-27 09:34:54,006 ERROR [STDERR] net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 117001, of class: com.azovstal.ugdt.hibernate.CodeCargo
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1881)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2132)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:109)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3440)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:177)
I do understand why its happening, what am I should write to avoid it?