Make a new entity instance managed and persistent, resulting in its insertion in the database when the persistence context is synchronized with the database, or make a removed entity managed, undoing the effect of a previous call to
EntityManager.remove. This operation cascades to every entity related by an association marked cascade=PERSIST. If the given entity instance is already managed, that is, if it already belongs to this persistence context, and has not been marked for removal, it is itself ignored, but the operation still cascades.- Parameters:
entity- a new, managed, or removed entity instance
- Throws:
- if the given instance is not an entity.IllegalArgumentException- if the given entity is detached (if the entity is detached, theEntityExistsExceptionEntityExistsExceptionmay be thrown when the persist operation is invoked, or theEntityExistsExceptionor anotherPersistenceExceptionmay be thrown at flush or commit time).- if there is no transaction when invoked on a container-managed entity manager that is of typeTransactionRequiredExceptionPersistenceContextType.TRANSACTION.
- Since:
- Jakarta Persistence (JPA) 1.0