2011-07-19 88 views
1

我有一個包含OtherFcs對象的IList中的對象OtherFaclilityEntity,並且映射如下:NHibernate的流利更新問題(一對多關係)

public OtherFacilityMap() 
    { 
     Schema("SOME"); 
     Table("OTHER_FACILITY"); 

     Id(x => x.Id, "OTHER_FACILITY_S").GeneratedBy.TriggerIdentity(); 
     Map(x => x.RowCreator, "ROW_CREATOR"); 
     Map(x => x.RowCreateDate, "ROW_CREATE_DATE"); 
     Map(x => x.Description, "DESCRIPTION"); 
     Map(x => x.ExistenceKdNm, "R_EXISTENCE_KD_NM"); 

     References(x => x.FacilityClassItem, "FACILITY_CLASS_S").LazyLoad(Laziness.False).Fetch.Join().Not.Insert().Not.Update(); 
     HasMany(x => x.FacilityCmList).KeyColumn("WHOLE_S").Fetch.Subselect().Not.LazyLoad(); 

    } 

當我嘗試做就OtherFacility一個SaveOrUpdate實體,它還會更新FacilityCmList,這是很好的所有實體,但在最後的SQL運行嘗試刪除和子對象的父之間的所有關係:

NHibernate.SQL: 2011-07-19 10:29:33,111 [361] DEBUG NHibernate.SQL [(null)] - UPDATE SOME.FACILITY_CMS SET WHOLE_S = null WHERE WHOLE_S = :p0;:p0 = '26021842' 

我認爲它有話與我的地圖,任何想法?

+0

解決問題,使用逆他牛逼,如下所示: http://stackoverflow.com/questions/4315791/nhibernate-sets-foreign-key-in-secondary-update-rather-than-on- initial-insert-vio – randoms

+0

您應該將其標記爲答案而不是評論。 –

+2

我必須等待8小時才能這樣做,因爲回覆率低:) – randoms

回答