Hi, I'm having some problem with the following mapping and request :
<class name="Edgar.Logistique.Core.Meuble, Edgar.Logistique.Core" table="TMBLPA">
<composite-id name="Cle" class="CleMeuble">
<key-property name="NumPermanentDepot" column="NOPMDP" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="5"/>
<key-property name="CodeReseauDepot" column="CDRSDP" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="1"/>
<key-property name="CodeTitre" column="CDTTPA" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="5"/>
<key-property name="NumParution" column="NONOPA" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="4"/>
<key-property name="SuffixeParution" column="CDSFPA" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="1"/>
<key-property name="CodeEdition" column="CDEDPA" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="2"/>
<key-property name="TypePreparation" column="TYPRPA" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="1"/>
<key-property name="DatePreparation" column="DTPRPA" type="AlDataAccess.NHibernateManager.CustomTypes.Int32Date, AlDataAccess"/>
<key-property name="NumMeuble" column="NONOMB" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess" length="3"/>
</composite-id>
<property name="EtatMeuble" column="CDETMB" length="1" type="AlDataAccess.NHibernateManager.CustomTypes.TrimmedChar, AlDataAccess"/>
...
<many-to-one name="DemandeEdition" class="DemandeEdition" update="false" insert="false" not-found="ignore">
<column name="NOPMDP"/>
<column name="CDRSDP"/>
<column name="DTPRPA"/>
<column name="NONOMB"/>
</many-to-one>
</class>
When I use the folling request :
requeteHQL.Append("select mbl from Meuble as mbl left join fetch mbl.DemandeEdition where"
+ " mbl.Cle.NumPermanentDepot = :numPermanentDepot"
+ " and mbl.Cle.CodeReseauDepot = :codeReseauDepot"
+ " and mbl.Cle.DatePreparation = :date");
Nhibernate does a left join fetch, retreiving the existing "DemandeEdition" instances from the database. My problem is that NHibernate then tries to load each instance of "DemandeEdition" that is null !!
The log looks this :
-> Existing instance :
2007-02-28 16:42:48,968 DEBUG NHibernate.Loader.Loader Hydrate [2/alteca2@mlp.fr] - Hydrating entity: Edgar.Logistique.Core.DemandeEdition#Edgar.Logistique.Core.CleDemandeEdition
2007-02-28 16:42:48,968 DEBUG NHibernate.Type.StringType NullSafeGet [2/alteca2@mlp.fr] - returning 'D' as column: CDEDET74_1_
2007-02-28 16:42:48,984 DEBUG NHibernate.Type.StringType NullSafeGet [2/alteca2@mlp.fr] - returning 'file.pdf ' as column: LBCHFL74_1_
2007-02-28 16:42:48,984 DEBUG NHibernate.Type.Int32Type NullSafeGet [2/alteca2@mlp.fr] - returning '20070228' as column: DTDDSM74_1_
2007-02-28 16:42:48,984 DEBUG NHibernate.Type.Int32Type NullSafeGet [2/alteca2@mlp.fr] - returning '115745' as column: HRDDSM74_1_
-> null instance :
resolving associations for: [Edgar.Logistique.Core.Meuble#Edgar.Logistique.Core.CleMeuble]
2007-02-28 16:42:56,765 DEBUG NHibernate.Impl.SessionImpl DoLoadByClass [2/alteca2@mlp.fr] - loading [Preparation#Edgar.Logistique.Core.ClePreparation]
2007-02-28 16:42:57,109 DEBUG NHibernate.Impl.SessionImpl DoLoadByClass [2/alteca2@mlp.fr] - loading [DemandeEdition#Edgar.Logistique.Core.CleDemandeEdition]
2007-02-28 16:42:57,125 DEBUG NHibernate.Impl.SessionImpl DoLoad [2/alteca2@mlp.fr] - attempting to resolve [DemandeEdition#Edgar.Logistique.Core.CleDemandeEdition]
2007-02-28 16:42:57,125 DEBUG NHibernate.Impl.SessionImpl DoLoad [2/alteca2@mlp.fr] - object not resolved in any cache [Edgar.Logistique.Core.DemandeEdition#Edgar.Logistique.Core.CleDemandeEdition]
2007-02-28 16:42:57,125 DEBUG NHibernate.Persister.Entity.AbstractEntityPersister Load [2/alteca2@mlp.fr] - Fetching entity: [Edgar.Logistique.Core.DemandeEdition#CleDemandeEdition{NumPermanentDepot=69022, CodeReseauDepot=P, NumMeuble=001, DatePreparation=09/02/2007 00:00:00}]
2007-02-28 16:42:57,125 DEBUG NHibernate.Loader.Loader LoadEntity [2/alteca2@mlp.fr] - loading entity: [Edgar.Logistique.Core.DemandeEdition#CleDemandeEdition{NumPermanentDepot=69022, CodeReseauDepot=P, NumMeuble=001, DatePreparation=09/02/2007 00:00:00}]
2007-02-28 16:42:57,125 DEBUG NHibernate.Impl.BatcherImpl LogOpenPreparedCommand [2/alteca2@mlp.fr] - Opened new IDbCommand, open IDbCommands: 1
2007-02-28 16:42:57,125 DEBUG NHibernate.Impl.BatcherImpl Generate [2/alteca2@mlp.fr] - Building an IDbCommand object for the SqlString: SELECT demandeedi0_.NOPMDP as NOPMDP74_0_, demandeedi0_.CDRSDP as CDRSDP74_0_, demandeedi0_.DTPRED as DTPRED74_0_, demandeedi0_.NOMBED as NOMBED74_0_, demandeedi0_.CDEDET as CDEDET74_0_, demandeedi0_.LBCHFL as LBCHFL74_0_, demandeedi0_.DTDDSM as DTDDSM74_0_, demandeedi0_.HRDDSM as HRDDSM74_0_ FROM TDDEED demandeedi0_ WHERE demandeedi0_.NOPMDP=? and demandeedi0_.CDRSDP=? and demandeedi0_.DTPRED=? and demandeedi0_.NOMBED=?
2007-02-28 16:42:57,125 DEBUG NHibernate.Type.StringType NullSafeSet [2/alteca2@mlp.fr] - binding '69022' to parameter: 0
2007-02-28 16:42:57,140 DEBUG NHibernate.Type.StringType NullSafeSet [2/alteca2@mlp.fr] - binding 'P' to parameter: 1
2007-02-28 16:42:57,140 DEBUG NHibernate.Type.Int32Type NullSafeSet [2/alteca2@mlp.fr] - binding '20070209' to parameter: 2
2007-02-28 16:42:57,140 DEBUG NHibernate.Type.StringType NullSafeSet [2/alteca2@mlp.fr] - binding '001' to parameter: 3
2007-02-28 16:42:57,140 INFO NHibernate.Loader.Loader GetResultSet [2/alteca2@mlp.fr] - SELECT demandeedi0_.NOPMDP as NOPMDP74_0_, demandeedi0_.CDRSDP as CDRSDP74_0_, demandeedi0_.DTPRED as DTPRED74_0_, demandeedi0_.NOMBED as NOMBED74_0_, demandeedi0_.CDEDET as CDEDET74_0_, demandeedi0_.LBCHFL as LBCHFL74_0_, demandeedi0_.DTDDSM as DTDDSM74_0_, demandeedi0_.HRDDSM as HRDDSM74_0_ FROM TDDEED demandeedi0_ WHERE demandeedi0_.NOPMDP=? and demandeedi0_.CDRSDP=? and demandeedi0_.DTPRED=? and demandeedi0_.NOMBED=?
2007-02-28 16:42:57,140 DEBUG NHibernate.SQL LogCommand [2/alteca2@mlp.fr] - SELECT demandeedi0_.NOPMDP as NOPMDP74_0_, demandeedi0_.CDRSDP as CDRSDP74_0_, demandeedi0_.DTPRED as DTPRED74_0_, demandeedi0_.NOMBED as NOMBED74_0_, demandeedi0_.CDEDET as CDEDET74_0_, demandeedi0_.LBCHFL as LBCHFL74_0_, demandeedi0_.DTDDSM as DTDDSM74_0_, demandeedi0_.HRDDSM as HRDDSM74_0_ FROM TDDEED demandeedi0_ WHERE demandeedi0_.NOPMDP=? and demandeedi0_.CDRSDP=? and demandeedi0_.DTPRED=? and demandeedi0_.NOMBED=?; p0 = '69022', p1 = 'P', p2 = '20070209', p3 = '001'
2007-02-28 16:42:57,140 DEBUG NHibernate.SQL LogCommand [2/alteca2@mlp.fr] - SELECT demandeedi0_.NOPMDP as NOPMDP74_0_, demandeedi0_.CDRSDP as CDRSDP74_0_, demandeedi0_.DTPRED as DTPRED74_0_, demandeedi0_.NOMBED as NOMBED74_0_, demandeedi0_.CDEDET as CDEDET74_0_, demandeedi0_.LBCHFL as LBCHFL74_0_, demandeedi0_.DTDDSM as DTDDSM74_0_, demandeedi0_.HRDDSM as HRDDSM74_0_ FROM TDDEED demandeedi0_ WHERE demandeedi0_.NOPMDP=? and demandeedi0_.CDRSDP=? and demandeedi0_.DTPRED=? and demandeedi0_.NOMBED=?; p0 = '69022', p1 = 'P', p2 = '20070209', p3 = '001'
2007-02-28 16:42:57,796 DEBUG NHibernate.Impl.BatcherImpl LogOpenReader [2/alteca2@mlp.fr] - Opened IDataReader, open IDataReaders: 1
2007-02-28 16:42:57,796 DEBUG NHibernate.Loader.Loader DoQuery [2/alteca2@mlp.fr] - processing result set
2007-02-28 16:42:57,796 DEBUG NHibernate.Loader.Loader DoQuery [2/alteca2@mlp.fr] - done processing result set (0 rows)
2007-02-28 16:42:57,843 DEBUG NHibernate.Driver.NHybridDataReader Dispose [2/alteca2@mlp.fr] - running NHybridDataReader.Dispose()
2007-02-28 16:42:57,843 DEBUG NHibernate.Impl.BatcherImpl LogCloseReader [2/alteca2@mlp.fr] - Closed IDataReader, open IDataReaders :0
2007-02-28 16:42:57,843 DEBUG NHibernate.Impl.BatcherImpl LogClosePreparedCommand [2/alteca2@mlp.fr] - Closed IDbCommand, open IDbCommands: 0
2007-02-28 16:42:57,843 DEBUG NHibernate.Loader.Loader InitializeEntitiesAndCollections [2/alteca2@mlp.fr] - total objects hydrated: 0
2007-02-28 16:42:57,843 DEBUG NHibernate.Loader.Loader LoadEntity [2/alteca2@mlp.fr] - done entity load
Does anyone have any idea on how to tell NHibernate not to try to load again my possibly null association ?
|