I don't have a reference to the session on my entity. Internally, it
redirects back to a static utility method that eventually gets a
session using the conversation model as described on
http://fabiomaulo.blogspot.com/2009/01/using-conversation-per-business.html.
The problem here is that I pass the wrong entity to that static
method.

The reason I am posting this on nhdevs is that I believe this may not
be ideally implemented. I can think of a number of use cases that
break through this implementation. For example, if you have business
logic on your entities (DDD) and you use the this pointer of the
entity to perform further actions, you are always passing the wrong
entity because the interceptor redirects everything to the
TargetInstance. NHibernate really doesn't know of the TargetInstance
and only just knows of the info.Target. This to me looks like a
deficiency in the implementation of lazy fields.

If I am overlooking something and you don't agree that this is an
issue with the implementation, I'd be happy to look for help in other
places.

On Feb 8, 4:10 pm, Diego Mijelshon <[email protected]> wrote:
> Well, not having a session reference in your entities would be a good start.
> If you like that kind of pattern, I recommend you use Castle ActiveRecord
> instead of implementing it yourself.
>
> On a different note, this list is only for development OF NHibernate. Try
> nhusers (or StackOverflow) for usage questions.
>
>     Diego
>
>
>
>
>
>
>
> On Wed, Feb 8, 2012 at 06:09, pvginkel <[email protected]> wrote:
> > I have a virtual method on my Entity base class which calls
> > session.SaveOrUpdate. When the entity has lazy fields, the
> > DefaultDynamicLazyFieldInterceptor calls the virtual method with the
> > TargetInstance and not the info.Target. This means that SaveOrUpdate
> > fails with a NonUniqueObjectException because I'm not passing the
> > proxy to SaveOrUpdate.
>
> > Is this behavior correct? If so, is there a way around this?

Reply via email to