@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:
<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.Rate, NHibernatCollections,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Rate`">
<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>
<discriminator type="String">
<column name="RateType" />
</discriminator>
<property name="ValidFrom" type="System.DateTime, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="ValidFrom" length="250" />
</property>
<property name="ValidTo" type="System.DateTime, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="ValidTo" length="250" />
</property>
<property name="Amount" type="System.Decimal, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Amount" length="250" />
</property>
<subclass name="NHibernatCollections.Models.HourlyRate,
NHibernatCollections, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" discriminator-value="HourlyRate" />
<subclass name="NHibernatCollections.Models.NightlyRate,
NHibernatCollections, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" discriminator-value="NightlyRate" />
</class>
</hibernate-mapping>
Regards,
Miha.
On Aug 16, 3:23 pm, Diego Mijelshon <[email protected]> wrote:
> Mappings?
>
> Diego
>
> On Mon, Aug 16, 2010 at 04:26, Miha V <[email protected]> wrote:
> > Hi!
>
> > I have a need to store several collections of the same "EntityType".
> > For instance, I have a class
>
> > public class HourlyRate
> > {
> > public virtual int Id { get; set; }
> > public virtual DateTime ValidFrom { get; set; }
> > public virtual DateTime ValidTo { get; set; }
> > public virtual decimal Amount { get; set; }
> > }
>
> > Then, on several entities, I would have
>
> > public class Employee {
> > public ISet<HourlyRate> RegularRates { get; set; }
> > public ISet<HourlyRate> NighltyRates { get; set; }
> > // etc.
> > }
>
> > I noticed that RegularRates and NighltyRates get mixed up in the
> > database -- they don't get stored as one would expect.
>
> > How to model this in OO terms so that NHibernate picks it up as
> > smoothly as possible?
>
> > I tried subclassing HourlyRate and that creates a table for each
> > "Rate", but I'd rather see that there would be a discriminator column
> > on the table holding HourlyRates. I tried changing the strategy to
> > table-per-subclass-hierarchy, but then I get WrongClassException when
> > loading entities.
>
> > Thanks,
> > Miha
>
> > --
> > 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]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
--
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.