JPA Method
in jakarta.persistence.EntityManager

void persist(
  Object entity
)


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 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:
EntityExistsException - if the given entity is detached (if the entity is detached, the {@code EntityExistsException} may be thrown when the persist operation is invoked, or the {@code EntityExistsException} or another {@code PersistenceException} may be thrown at flush or commit time)
IllegalArgumentException - if the given instance is not an entity
TransactionRequiredException - if there is no transaction when invoked on a container-managed entity manager that is of type {@link PersistenceContextType#TRANSACTION}
Since:
JPA 1.0