Query cache holds stale data from custom sql queries

Description

The quera cache holds stale data from custom sql queries, because NHibernate gets no query spaces from those queries.

When NHibernate asks the cache if the data is up-to-date, the cache gets no query spaces and answer is always "true".

NHibernate has to extract the query spaces out of the sql query. If that's not possible, there should be a method to manually give the query spaces to the query...

In addition to this issue the timestamp that is used for the query cache is the one from the current session. The problem is that this timestamp stays the same as long as the session lives. In the comparision of the timestamps (last update <-> last read), the saved timestamp is always the same in one session. it has to refresh when the query is re-read.
I have tested this with replacing the session.Timestamp in the StandardQueryCache.Put() method with Timestamper.Next() and it seems to work properly.

Environment

None

Attachments

1

Activity

Show:

Frédéric DelaporteJuly 8, 2018 at 12:20 PM

Moved here, and fixed with #1381 (v5.2). It requires some changes in user code: sql queries must declare their query spaces for them to get invalidated by updates.

Tuna ToksozOctober 10, 2008 at 11:28 AM

Can you attach tests for this, Manuel?

Manuel RenneckeJuly 8, 2008 at 12:28 AM

Added a patch for this issue. After applying this patch all queryspaces/table names will be extracted from custom sql queries automatically. Then the query cache will be invalidated correctly on updates...

Fabio MauloJuly 7, 2008 at 9:52 AM

If you are using sql-query in the mapping you can use the <synchronize> tag.
BTW is true that you can't add query spaces, to a sql-query, at run-time.
Changed type to improvement and scheduled for NH2.1.0.

Obsolete

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created May 8, 2008 at 11:23 PM
Updated July 8, 2018 at 12:20 PM
Resolved July 8, 2018 at 12:20 PM
Who's Looking?
Loading...