the session-cache doesn't not know what mean "invalidate". An entity instance is in the session-cache or is not in the session-cache. The "invalidation" is a concept of cache (aka second-level-cache).
If you are generating values in the DB at each insert/update you have to inform NH through the "generated" attribute of each property affected by the remote generation. On Thu, Sep 30, 2010 at 11:32 AM, Yauhen <[email protected]> wrote: > I simply need invalidate cache. So next call not get value fro cache > but from real database. > > On Sep 30, 5:27 pm, Roger Kratz <[email protected]> wrote: > > I'm not sure I understand but... > > > > << [...] Session is the same betwwen calls. [...]>> > > << [...] query.ExecuteUpdate(); [...] >> > > > > Are you expecting your call to ExecuteUpdate to update the state inside > your ISession? I don't think that will work. > > > > Session keeps a first level cache. The state of this cache won't be > updated when calling ExecuteUpdate AFAIK - no entities are returned. > > > > /Roger > > > > > > > > -----Original Message----- > > From: [email protected] [mailto:[email protected]] On > Behalf Of Yauhen > > Sent: den 30 september 2010 16:10 > > To: nhusers > > Subject: [nhusers] Re: NHibernate cache > > > > so nobody has ideas? > > > > On Sep 28, 12:50 pm, Yauhen <[email protected]> wrote: > > > I have found very strange effect when using nhibernate. > > > I am trying to do one clever update operation. Then read saved data > > > from database. > > > Operations are mostly based on sql queries. In database data are ok. > > > But by some strange reason nhibernate uses cached old data. > > > Operations are described like following: > > > <class name="Message" table="Messages" > > > > <id name="Id" type="Int32" column="Id"> > > > <generator class="identity"/> > > > </id> > > > <property name="Subject" column="Subject" > type="String"/> > > > <property name="CategoryId" column="CategoryId" > type="Int32"/> > > > > > <sql-query name="Message.Delete"> > > > <synchronize table="Messages"/> > > > UPDATE Messages > > > SET CategoryId = ( /* long select to decide to which category to > > > move*/ > > > ) > > > WHERE Id = :messageId > > > </sql-query> > > > > > <sql-query name="Message.GetDetails"> > > > <return alias="msg" class="Message"/> > > > SELECT {msg.*} > > > FROM Messages {msg} > > > WHERE msg.Id = :messageId > > > </sql-query> > > > > > when calling delete/update query I use syntax like following > > > using (ITransaction trans = _session.BeginTransaction()) > > > { > > > IQuery query = > > > _session.GetNamedQuery("Message.Delete"); > > > query.SetParameter<IdT>(paramName, id); > > > query.ExecuteUpdate(); > > > trans.Commit(); > > > > > _session.Flush(); > > > } > > > when calling read: > > > IQuery query = _session.GetNamedQuery("Message.GetDetails"); > > > query.SetInt32("messageId", messageId); > > > query.List<Message>(); > > > > > Session is the same betwwen calls. Caching occurs somewhere inside > > > NHibernate.Loader > > > > > obj = session.GetEntityUsingInterceptor(key); > > > > -- > > 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 athttp:// > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Fabio Maulo -- 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.
