BTW, I _had_ to change the OO model in order for this to work.
I introduced a Rate abstract base class and use derived classes
HourlyRate and NightlyRate for that.
public abstract class Rate
{
public virtual int Id { get; set; }
public virtual DateTime ValidFrom { get; set; }
public virtual DateTime ValidTo { get; set; }
public virtual decimal Amount { get; set; }
}
public class HourlyRate : Rate {}
public class NightlyRate : Rate { }
And Employee has:
public class Employee
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
private ISet<HourlyRate> _regularRates = new
HashedSet<HourlyRate>();
public virtual ISet<HourlyRate> RegularRates
{
get { return _regularRates; }
set { _regularRates = value; }
}
private ISet<NightlyRate> _nightlyRates = new
HashedSet<NightlyRate>();
public virtual ISet<NightlyRate> NightlyRates
{
get { return _nightlyRates; }
set { _nightlyRates = value; }
}
}
And the mapping for an Employee:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
name="NHibernatCollections.Models.Employee, NHibernatCollections,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
table="`Employee`">
<id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Id" />
<generator class="hilo">
<param name="max_lo">100</param>
</generator>
</id>
<property name="Name" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Name" length="250" />
</property>
<set cascade="all" name="RegularRates" mutable="true">
<key>
<column name="Employee_id" />
</key>
<one-to-many class="NHibernatCollections.Models.HourlyRate,
NHibernatCollections, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
</set>
<set cascade="all" name="NightlyRates" mutable="true">
<key>
<column name="Employee_id" />
</key>
<one-to-many class="NHibernatCollections.Models.NightlyRate,
NHibernatCollections, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
</set>
</class>
</hibernate-mapping>
On Aug 16, 3:52 pm, Miha V <[email protected]> wrote:
> @Thiago - I'm using FNH to generate the mappings, and Override with
> Where does not seem to go into the mapping file itself.
>
> @Diego, mapping file for Rate is:
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.