I have looked around quite a bit and found many examples on how to map children, but I am missing something. I cannot get the follwing mapping to work
Table 1:
ORDERID RAW No
HISTORYID RAW No
Mapping:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping auto-import="false" xmlns="urn:nhibernate-mapping-2.2">
<class name="Order" lazy="false" table="Orders" polymorphism="explicit" dynamic-insert="true">
<id name="OrderId" column="OrderId" type="Guid">
<generator class="GuidGenerator" />
</id>
<bag name="OrderHistoryBag" lazy="false" table="OrderHistory" cascade="none">
<key column="HistoryId" />
<one-to-many class="OrderHistory" not-found="ignore" />
</bag>
</class>
</hibernate-mapping>
Class Properties:
public virtual IList<OrderHistory> OrderHistoryBag { get; set; }
public virtual Collection<OrderHistory> OrderHistory { get; set; }
Table 2:
HISTORYSEQ NUMBER(6,0) No
HISTORYID RAW Yes
Mapping:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OrderHistory" lazy="false" table="OrderHistory" polymorphism="explicit">
<id name="HistorySequence" column="HistorySeq" type="Int32">
<generator class="sequence">
<param name="sequence">S_Hist</param>
</generator>
</id>
<many-to-one name="Order" class="Order" column="HistoryId" not-null="true" cascade="none" lazy="false" />
</class>
</hibernate-mapping>
Class Property:
public virtual Order Order { get; set; }
Everything compiles and runs fine except that the OrderHistoryBag and its assocaiated OrderHistorycollection are always an empty collection.
I guess the short story is that I'm trying to map HistoryId in the parent class to HistoryId in the child class neither of which are primary keys on the entities. My NHibernate assemblies are v1.2.1.400 (Don't ask).