Im working with a framework, where NHibernate is not king and ruling everything. So this developer would be very happy if NH could be so kind ;-)
We have different kind of interceptors, where it would be really nice and handy if NH could expose this knowledge, so we could invoke a specific kind of interceptors. The NH built-in interceptor wont do it. On Fri, Dec 10, 2010 at 2:32 PM, Jason Meckley <[email protected]>wrote: > these are lower level concerns within NH that a developers shouldn't > need to think about. the session itself implements an identity map > which is responsible for ensuring exactly 1 instance of an entity > exists per session. > > Get() and Load() use the identity map to determine if the entity is > already loaded so you don't query the database twice. a query will > retrieve the entity from the database, but if the entity is already > loaded in the session that instance will be returned instead of the > results from the database. for example > > //table Entity > //columns Id int, Name varchar > //row 1, "old name" > > var entity = session.Get<Entity>(1); > // result from database is row [1, "old name"] > // entity[1] loaded into session's identity map (IM) > > entity.Name = "new name"; > // entity[1] in IM Name property is changed > > var entity = session > .CreateQuery("from Entity where id = :id") > .SetParameter("id", 1) > .Unique<Entity>(); > // result from database is row [1, "old name"] > // entity[1] already exists in the IM as Entity{Id = 1, Name = "new > name"} > > Assert.That(entity.Name, Is.EqualTo("new name")); > // should pass > > Hopefully that clears things up. > > On Dec 10, 7:55 am, Jacob Madsen <[email protected]> wrote: > > Hi there, > > > > Hope one of you can help me with 2 questions: > > > > 1) How do I ask a session if a specific entity is dirty / has changed? > > > > 2) Will ISession.Contains(entity) return true for any session-tracked > > entity, no matter how the entity was loaded / queried / retrieved? > > -- > 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. > > -- 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.
