Tom,
even if I change my implementation to IList, the result is the same.
The problem with loading is that the SQL query which is issued is:
NHibernate: SELECT regularrat0_.Employee_id as Employee6_1_,
regularrat0_.Id as Id1_, regularrat0_.I
d as Id1_0_, regularrat0_.ValidFrom as ValidFrom1_0_,
regularrat0_.ValidTo as ValidTo1_0_, regularra
t0_.Amount as Amount1_0_ FROM "Rate" regularrat0_ WHERE
regularrat0_.employee_...@p0;@p0 = 101
Clearly, it is missing a WHERE condition on a discriminator column.
The INSERT statement is:
NHibernate: INSERT INTO "Rate" (ValidFrom, ValidTo, Amount, RateType,
Id) VALUES (@p0, @p1, @p2, 'HourlyRate',
@p3);@p0 = 1.1.1995 0:00:00, @p1 = 9.10.2009 0:00:00, @p2 = 17, @p3 =
202
You can see that INSERTs are constructed with the "Type" parameter
with value "HourlyRate" whereas SELECTs are missing this piece of
information. The way I'm querying is:
var emps = _session.CreateCriteria<Employee>().List<Employee>();
foreach (var emp in emps)
{
ListRates(emp.RegularRates);
}
The project file is located here if someone would take a look:
http://dl.dropbox.com/u/163584/NHibernatCollections.zip
Fabio,
from what I read in the ConfORM comments, this stuff is _not_
supported? Meaning that I should specify the "WHERE" clause? This
seems to be a bug in FNH because it does not take WHERE condition into
account.
*********
UPDATE: I was able to instruct FNH to generate the where clauses. I
was "overriding" it like so in the beginning:
.Override<HourlyRate>(map => map.Where("RateType = 'HourlyRate'"))
but then I tried
.Override<Employee>(map => map.HasMany(m =>
m.RegularRates).Where("RateType = 'HourlyRate'"))
.Override<Employee>(map => map.HasMany(m =>
m.NightlyRates).Where("RateType = 'NightlyRate'"))
and this seems to works for now. So I was using FNH the wrong way.
Seems I'm all set for now.
And, on a related note, it seems that I need to invest some time into
ConfORM as wel.
Thanks guys!
Miha.
On Aug 17, 5:37 pm, Fabio Maulo <[email protected]> wrote:
> http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm.Sh...
> <http://code.google.com/p/codeconform/source/browse/ConfOrm/ConfOrm.Sh...>Have
> a look to comments...
>
> btw... implements a patternapplier to autodiscover double-usage of a class
> in collection-owner is easy.
>
>
>
> On Tue, Aug 17, 2010 at 11:50 AM, Tom Bushell <[email protected]> wrote:
> > Miha,
>
> > I am also using FNH automapping in my project, and have a similar
> > requirement to map multiple ILists of the same type in some of my
> > classes.
>
> > Following advice from the FNH mailing list, I ended up with a solution
> > almost identical to yours, a base class (though it's not defined as
> > Abstract), and a derived class for each IList that is a member of the
> > same class.
>
> > This Automaps perfectly well _as is_ - no overrides, no where clauses,
> > no mapping files are needed.
>
> > I see you are using ISets, not ILists, and am not sure if Automapping
> > supports ISets. But I know this approach works very well with ILists.
>
> > The other difference I see is that you are using private backing
> > variables for your ISets. This is a fairly recent addition to FNH
> > Automapping that was not available to me several months ago when I
> > started my project.
>
> > >Again: it works for saving, but does not work for loading entities.
>
> > What happens when you load?
>
> > -Tom Bushell
>
> > --
> > 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.
>
> --
> Fabio Maulo
--
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.