persist

Die Methode void persist(Object entity) gehört zum EntityManager Interface. Wenn das übergebene Entity ein neues Entity ist, wird es zu einem Managed Entity und bei einem flush oder vor dem Commit der Transaktion in die Datenbank eingefügt. Wenn das übergebene Entity schon ein Managed Entity ist, werden keine zusätzlichen Operationen durchgeführt. Wenn das übergebene Entity ein Detached Entity ist, kann eine EntityExistsException ausgelöst werden (entweder sofort oder beim flush), was zum Rollback der Transaktion führt.

/**
* Make an instance managed and persistent.
* @param entity
* @throws EntityExistsException if the entity already exists.
* (The EntityExistsException may be thrown when the persist
* operation is invoked, or the EntityExistsException or
* another PersistenceException may be thrown at flush or
* commit time.)
* @throws IllegalArgumentException if not an entity
* @throws TransactionRequiredException if invoked on a
* container-managed entity manager of type
* PersistenceContextType.TRANSACTION and there is
* no transaction.
*/