As far as I have found it is not possible.
See comments in article.
http://ayende.com/Blog/archive/2009/05/28/nhibernate-ndash-executable-dml.aspx
So the only way is to use Evict. But in this case we need to have
object.
Alternatively session should be closed.


On Sep 30, 5:09 pm, Yauhen <[email protected]> wrote:
> 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].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to