MultiIdentifierLoadAccess ignores the 2nd level cache
Description
Activity
Show:

Barnaby Court September 3, 2018 at 8:43 PMEdited
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.
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.