Notify second-level cache when no results were got from DB

Description

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:

Environment

Hibernate 4.2.5, db PostgreSQL

Assignee

Unassigned

Reporter

ДанилоH

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure