Hi,

I think this is a day for working through my misconceptions about NH.
Can someone confirm this is correct behaviour?

1) I get a key from the UI (Web page so I store the key only for
performance)
2) I create a proxy in NH using Session.Load in my UI. I assume the
row matching the ID exists because I selected it previously.
3) I pass this proxy to my service layer to do some work against it
4) Service layer uses the ID of the entity *and nothing else at this
point*
5) NH hits the DB

(4) is what has thrown me. I always thought (based on blog posts etc.)
that if you only ever access the ID of a proxy, the DB is never hit.
It appears that isn't the case.

Is this correct behaviour, bug, or feature of Session.Load as opposed
to proxies for a Lazy Load?

It's a problem as in my service layer I perform logic based on the ID,
including, a check for "well, you thought it existed, but in the
meantime someone else has deleted it whilst you were away having a cup
of coffee".

This check is failing as I assume I can use the ID, but actually I
can't as this throws an NH exception.

Any confirmation or advice for my scenario (except for just catch the
NH error - I'd rather to a Try rather than a straightforward catch of
an expected exception).

Thanks

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