See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/Getting.20reference.20to.20a.20potentially.20detached.20entity
[getReference(Object) is] the only way to safely get an attached instance of a detached entity without merging it. Critically, it's hard to get the ID of a detached entity in a completely safe way. Session#getIdentifier doesn't work on detached entities, and {{PersistenceUnitUtil#getIdentifier}}won't work on detached entities whose ID contains an association.
In this case I think the patch would be limited to adding one method to Session, and that method wouldn't even be an overload (since there's no getReference method with one parameter), so the [backporting] seems pretty safe.
|