Hiya,

A developer on my team raised an issue today and it threw me a little
as the behaviour he reported wasn't was I was expecting.

He is running through a loop, doing an HNibernate Linq query (which
resolves down to a Critera query). Based on the results he either adds
or updates then, once all objects are processed he does a Flush.

(psuedo code)

foreach entity
    Run Linq Query to match on entity.surname= "xyz"   //i.e. not the
key value
    if query.count ==0
        Session.Add(entity)
    else
        Get the First entity from the query (i.e. results.First()  )
        Update values
        Session.Update(entity)
endfor

Session.Flush()

The Linq/Critera query is hitting the DB each time instead of checking
the Session first to see if the object exists in the session already.
Therefore if a second entity is hit in the foreach, with the same
surname, the Linq query hits the DB again and doesn't find it as the
Flush hasn't taken place yet.

I may be answering my own question here but...

Is NHibernate hitting its own session before running the linq query
but not finding a match so runs the Query? If so,how does it identify
a match in its own 1st level cache?
--~--~---------~--~----~------------~-------~--~----~
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