-
Notifications
You must be signed in to change notification settings - Fork 936
Description
Refer to https://hibernate.atlassian.net/browse/HHH-5210
When using a query which is marked as cacheable, NHibernate caches both the query with the session timestamp, and its last invalidation timestamp (due to an update or save). When retrieving a query from the cache, it first compares the timestamp of the cached query with the last invalidation timestamp (UpdateTimestampsCache.IsUpToDate()
):
if ((long) lastUpdate >= timestamp)
{
return false;
}
The problem is that the timestamp for the current session, used for caching query, is always lower than invalidation's timestamp if the entities were altered in the session, even prior to caching the query and in a dedicated transaction. This causes the result of the method to be always false
, discarding the cache results and hitting the database forever with that session.