c# - NHibernate mapping bag with keys from property of a property -
i have following structure:
public class version { public status status; } public class status { action action; area area; public ilist<version> versions } public class action { public int id; } public class area { public int id; }
and map list of versions bag, might mapping wrong way. here parte of status.hbm.xml file maps list:
<bag name="versions" cascade="save-update" inverse="true" lazy="true" generic="true" order-by="num_version desc"> <key> <column name="id_action"></column> <column name="id_area"></column> </key> <one-to-many class="version" /> </bag>
id_action
, id_area
foreign keys status
, property of version
. need reference status
on bag mapping? how supposed map case?
thank you
i able find problem: mapping used on answer correct. however, needed inverse order of columns on mapping. because both keys (action , area) must in same order defined in mapping of status.hbm.xml file.
so, correction doing this:
<bag name="versions" cascade="save-update" inverse="true" lazy="true" generic="true" order-by="num_version desc"> <key> <column name="id_area"></column> <column name="id_action"></column> </key> <one-to-many class="version" /> </bag>
Comments
Post a Comment