JPA - Managed Entity

> JPA - Java Persistence API (JPA)

1 - About

future updates to the entity will be tracked.

The behavior is undefined if the same Java instance is made managed in more than one persistence context

Advertising

3 - Management

3.1 - Contains

The contains() method can be used to determine whether an entity instance is managed in the current persistence context.

The contains method returns true:

  • If the entity has been retrieved from the database or has been returned by getReference, and has not been removed or detached.
  • If the entity instance is new, and the persist method has been called on the entity or the persist operation has been cascaded to it.

The contains method returns false:

  • If the instance is detached.
  • If the remove method has been called on the entity, or the remove operation has been cascaded to it.
  • If the instance is new, and the persist method has not been called on the entity or the persist operation has not been cascaded to it.

4 - Documentation / Reference