Query cache holds stale data from custom sql queries
Description
Environment
None
Attachments
1
Activity
Show:

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.
Who's Looking?
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.