MultiIdentifierLoadAccess ignores the 2nd level cache

Description

When using the session.byMultipleIds(...).enableSessionCheck(true).multiLoad(...) to load a set of entities that are already cached in the 2nd level cache a full query against the database is performed. I would have expected either another flag such as enableSecondLevelCacheCheck() to enable checking of the second level cache or for the cache to be checked automatically when the sessionCheck() is enabled. When using immutable entities this type of feature could avoid a great deal of database load.

Activity

Show:

Barnaby Court September 3, 2018 at 8:43 PM
Edited

I looked into adding the enableSeconLevelCacheCheck() to org.hibernate.internal.SessionImpl.MultiIdentifierLoadAccessImpl but I wasn't sure the proper way to actually load the entities from the 2nd level cache from within org.hibernate.loader.entity.DynamicBatchingEntityLoaderBuilder#performUnorderedMultiLoad.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created September 3, 2018 at 4:03 PM
Updated August 29, 2024 at 12:15 PM
Resolved October 31, 2018 at 5:45 PM