У меня есть следующие критерии:
session.CreateCriteria<ItemDeliveryDetail>()
.SetFetchMode("ItemDelivery", FetchMode.Eager)
.Add(Restrictions.Eq("Id", 21932250))
.List<ItemDeliveryDetail>();
Это приводит к следующему запросу:
SELECT this_.itemdeliverydetail_id AS itemdeli1_4_0_,
this_.itemdelivery_id AS itemdeli2_4_0_,
this_.partitiondate AS partitio3_4_0_,
this_.amount AS amount4_0_,
this_.processed_by_rem AS processed5_4_0_,
this_.single_item_price AS single6_4_0_,
this_.bookingaccount_id AS bookinga7_4_0_,
this_.supplierinvoice_id AS supplier8_4_0_
FROM itemdeliverydetail this_
WHERE this_.itemdeliverydetail_id = :p0;
Как видите, нет признаков присоединения к ITEMDELIVERY
как я и ожидал.
Как это исправить?
Отображение ItemDelivery
выглядит так:
mapping.CompositeId().KeyProperty(x => x.Id, "ITEMDELIVERY_ID")
.KeyProperty(x => x.DeliveryDate, "DELIVERY_DATE");
mapping.HasMany(x => x.ItemDeliveryDetails)
.KeyColumns.Add("ITEMDELIVERY_ID", "PARTITIONDATE");
Отображение ItemDeliveryDetail
выглядит так:
mapping.CompositeId().KeyProperty(x => x.Id, "ITEMDELIVERYDETAIL_ID")
.KeyReference(x => x.ItemDelivery, "ITEMDELIVERY_ID",
"PARTITIONDATE");