jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
187 stars 55 forks source link

Add getReference(detachedEntity) to EntityManager #489

Closed gavinking closed 10 months ago

gavinking commented 10 months ago

A very useful operation that we recently added in Hibernate is this one:

<T> T getReference(T object);

It's job is to turn a reference to a detached entity into a reference associated with the persistence context.

It's just a shortcut way to write:

em.getReference(entity.getClass(),entity.getId())

I know it seems like a completely trivial little thing, but sometimes conveniences like this can be very helpful.