Hi Jason,

Good tip, unfortunately it yields exactly the same results using the
following code (that doesn't include any repository abstraction)

using (var session2 = sessionFactory.OpenSession()) {
        using (var tx = session2.BeginTransaction()) {
                session2.Save(s1);
                session2.Save(s2);
                session2.Save(s3);
                tx.Commit();
        }
        using (var tx = session2.BeginTransaction()) {
                session2.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session2.BeginTransaction()) {
                session2.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session2.BeginTransaction()) {
                session2.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
}

using (var session3 = sessionFactory.OpenSession()) {
        session3.Get<Survey>(s1.Id);
        using (var tx = session3.BeginTransaction()) {
                session3.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session3.BeginTransaction()) {
                session3.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session3.BeginTransaction()) {
                session3.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
}

using (var session4 = sessionFactory.OpenSession()) {
        session4.Get<Survey>(s1.Id);
        using (var tx = session4.BeginTransaction()) {
                session4.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session4.BeginTransaction()) {
                session4.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
        using (var tx = session4.BeginTransaction()) {
                session4.QueryOver<Survey>().WhereRestrictionOn(s =>
s.Name).IsLike("Sur", MatchMode.Anywhere).Cacheable().List<Survey>();
                tx.Commit();
        }
}


Any fetching query made during "session2" seem to be disregarded for
caching since we are modifying the "Survey"-table that the query will
be querying, this despite the fact that the inserts are made in a
transaction that is finished before any queries to it. From what I can
tell from what Oren was saying on his blog, this has to do with the
fetching queries get the timestamp of when the session was openend.
That would explain the behavior I'm seeing but it still feels very
odd. I was hoping someone could explain, if this is really the case,
and if it is, why doesn't the queries get timestamped with the
transaction time?

Cheers!


On 21 Feb, 00:56, Jason Meckley <[email protected]> wrote:
> i would start by removing the repository. at least to understand the
> concepts of how 2nd level cache works. get the queries/cache working using
> pure NH. then introduce the repository objects. With this approach you can
> narrow down the problem to a 2nd level cache misconfiguration, or a problem
> with your repositories.

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