|
When one do
> session.get(Class, id)
and gets NULL because no such object was found in DB, second-level cache is not notified about this. Thus it cannot cache result "no result" and cache-lookup fails.
The problem hides in method Loader.initializeEntitiesAndCollections(). Cache is never notified, because there is no cache-friendly method like TwoPhaseLoad.initializeEntity() for situation when result set is empty.
Cacheable queries can solve this problem, but they look more like hack. Proposed improvement will help to implement cacheable null values (which are supported in, e.g, EHcache)
Related issue:
HHH-3522
|