I am stumped on how to use the 'Where' clause in a one-to-many bag collection when the select is NOT based in the parent's id column, but rather on another column of the parent.
I have two tables involved: Job (the parent) and JobInfoBTRes (the child collection elements).
The SQL statement should have the meaning of:
Select * from JobInfoBTRes where JobInfoBTRes.bt_pkey = Job.bt_pkey
How do I map the one-to-many relationship?
** I removed some property defnitions for simplicity **
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Framework.Model.Job, Framework" table="Job" lazy="false">
<id name="id" column="job_pkey" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="BtPKey" column="bt_pkey" not-null="true"/>
<!-- One-to-many mapping: where [dbo].[Job].[bt_pkey] = [dbo].[JobInfoBTRes].bt_pkey-->
<bag name="JobInfoBTResList" cascade="all" inverse="true" lazy="false" where="bt_pkey = bt_pkey">
<key column="bt_pkey" />
<one-to-many class="Framework.Model.JobInfoBTRes, Framework" />
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Framework.Model.JobInfoBTRes, Framework" table="JobInfoBTRes" lazy="false">
<id name="PKey" column="Jibd_PKey" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="BtPKey" column="bt_pkey" not-null="true"/>
<property name="ShowsOnBook" column="showsonbook" not-null="false"/>
</class>
</hibernate-mapping>
[/code]