Hi!

The same happened to me.
After a lot of googling I tried to use
where="<discriminator_column>=''<discriminator_value>" in the relationship
tag.

Eg: <many-to-many ..... where="TIP_ATIVIDADE='M'">

This solved the WrongClassException for me (but I still wonder why is this
necessary since I used <discriminator force="true" /> in my situation, which
is slightly different from yours). I suggest you give it a try.

Best Regards,
Thiago Alves


On Mon, Aug 16, 2010 at 4:26 AM, 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.

Reply via email to