My mapping was in CustomerMutzar :

  HasMany<CustomerMutzarKishur>(x => x.Col_CustomerMutzarKishur)


Class Diagram of my entity model was :

The mistake I’ve got in NHibernate Profiler :

it does the select query :

       left outer join CUSTOMER_MUTZAR_KISHUR col_custom1_
         on customermu0_.CMU_RECID = col_custom1_.CMK_CMU_RECID
       left outer join CUSTOMER_MUTZAR_PRODUCT customermu2_
         on col_custom1_.CMK_CMP_RECID = customermu2_.CMP_RECID
WHERE  customermu0_.CMU_RECID = 450 /* :p0 */


and then I get few problematic statements in profiler :

fail-safe cleanup (collections) : NHibernate.Engine.Loading.CollectionLoadContext<rs=System.Data.OracleClient.OracleDataReader>

On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries

and a system crash from log  :

StackTrace: NHibernate.PropertyAccessException: Invalid Cast (check your mapping for property type mismatches); setter of Ness.DoarKamuti.Infrastructure.Entities.CustomerMutzar —> System.InvalidCastException: Unable to cast object of type ‘NHibernate.Collection.Generic.PersistentGenericSet`1[Ness.DoarKamuti.Infrastructure.Entities.CustomerMutzarKishur]’ to type ‘System.Collections.Generic.IList`1[Ness.DoarKamuti.Infrastructure.Entities.CustomerMutzarKishur]’.
   at (Object , Object[] , SetterCallback )

The Solution :

I went again to the mapping of the entity and adjusted the relationships :


 HasMany<CustomerMutzarKishur>(x => x.Col_CustomerMutzarKishur).AsBag()

This has resolved the issue for me.