An entity is considered associated with the Session if it contains a corresponding “entry”. As detach and clear need to disassociate the entity from the Session, its necessary that their entries are removed. It’s really up to us what we want to do with natural-id caches as that feature is entirely behind the scope of the JPA spec. That said, I tend to agree that we should not remove the cross-references from the natural-id second-level cache nor do we really need to remove it from the natural-id Session cache. |