*Person* entity references one *Nickname* entity having foreign key *on delete set null*.
If _Person entity is stored in second level cache and her Nickname_ entity is deleted by a native query, then the reference id is set to null in database, but the cached _Person_ entity still has the old reference id.
Loading the _Person_ from second level cache (entitymanager.find) tries to load the old _Nickname_ that doesn't exist, throws _EntityNotFoundException_ that cascades and ultimately returns a *null Person* object.
Person _Person_ entity still *exists* in database and should have been found and the invalid reference should be resolved somehow (maybe recheck in database). |
|