Fixed
Details
Assignee
Yoann RodièreYoann RodièreReporter
Yoann RodièreYoann RodièreComponents
Sprint
NoneFix versions
Priority
Major
Details
Details
Assignee
Yoann Rodière
Yoann RodièreReporter
Yoann Rodière
Yoann RodièreComponents
Sprint
None
Fix versions
Priority
Created November 14, 2020 at 8:06 AM
Updated November 23, 2020 at 2:06 PM
Resolved November 16, 2020 at 9:49 AM
Search.session()
creates aLazyInitSearchSession
that retrieves the actual underlyingSearchSession
lazily upon first access, and then caches it.This means that, if you call
Search.session
on aSession
proxy that relies on thread-locals to redirect calls to the actual session (e.g.sessionFactory.getCurrentSession()
, or Spring EntityManager proxies), the resultingSearchSession
will always delegate to theSession
from the first thread. This is problematic for many reasons: thread-safety (a session will be accessed from concurrent threads), search (we'll retrieve entities from an unrelated session), indexing (we'll add indexing operations to the wrong session/transaction), ...