I think that you either have to map CurrentAssignment with lazy="false" or
use proxies.
Anyway, there are several ways to work around the polymorphic issue that you
mention:
http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html
http://mijalko.blogspot.com/2009/03/hibernate-nhibernate-and-polymorphism.html
http://groups.google.com/group/nhusers/browse_thread/thread/098bba5baa322009/3dda9af9eca62271?hl=en&pli=1


On Fri, Mar 27, 2009 at 2:08 PM, Peter Morris <[email protected]> wrote:

>
> >I mean, i have a service, i request an object, i don't know why i'm asking
> > for it?
>
> Correct.
>
>
> > In general for a really complex system I build a DTO to send to the
> > client,
>
> Imagine the app manages the automatic payment of allowances on a period
> basis.  The client has just indicated that Employee#1 should have their
> allowances payed immediately, so the app layer would look something like
> this
>
>
> public void PayImmediately(int employeeNumber)
> {
>    //Get employee
>    Employee emp = EmployeeRepository.GetByEmployeeNumber(employeeNumber);
>
>    //Make payments
>    AllowanceService.PayAllowances(emp.CurrentAssignment);
> }
>
> Now this is all happening within a single ISession (I'm just not showing
> that part).  When the EmployeeRepository fetches the Employee it only
> fetches the Employee state, for the AllowanceService.PayAllowances to work
> it needs lots of information such as which allowances have been assigned to
> the employee, this is fine though because they are multi-associations and
> as
> such can easily be fetched on demand, but what about the single links?
>
> For example, here I am asking for allowances from the employee's current
> assignment.  The current assignment is a single-link, but the repository
> has
> no way of knowing I was going to need that and so it didn't fetch it.  In
> this case the Employee isn't mapped to eagerly fetch CurrentAssignment
> because it is only used in about 50% of the time, so unless I use proxies +
> mark my properties virtual the service is going to read it as NULL isn't
> it?
> But then if I do use proxies I am going to run into this polymorphic
> multi-association bug because Allowance is a base class form which I
> descend
> multiple classes (allowance types).  Apart from which, the idea of making
> my
> properties virtual makes me feel ill :-)
>
> Pete
> ====
> http://mrpmorris.blogspot.com
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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