JPA Method
in jakarta.persistence.EntityManager

void detach(
  Object entity
)


Evict the given managed or removed entity from the persistence context, causing the entity to become immediately detached. Unflushed changes made to the entity, if any, including deletion of the entity, will never be synchronized to the database. Managed entities which reference the given entity continue to reference it. This operation cascades to every entity related by an association marked cascade=DETACH. If the given entity instance is new or detached, that is, if it is not associated with this persistence context, it is ignored.
Parameters:
entity - a managed or removed entity instance
Throws:
IllegalArgumentException - if the instance is not an entity
Since:
JPA 2.0