Class EntityExistsException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
jakarta.persistence.PersistenceException
jakarta.persistence.EntityExistsException
- All Implemented Interfaces:
Serializable
Thrown by the persistence provider when:
- a detached instance of an entity type is passed to
EntityManager.persist(Object), or - any kind of uniqueness constraint is violated when an entity is inserted in the database.
The persistence provider is always permitted to postpone
an EntityExistsException until execution of the
resulting database insert operation. If a detached instance
is passed to the persist operation, either:
- an
EntityExistsExceptionis immediately thrown bypersist(), or - an
EntityExistsExceptionor some other subtype ofPersistenceExceptionis thrown when the persistence context is flushed or when the transaction commits.
If an EntityExistsException is thrown by an
EntityManager with a persistence context joined to
an active transaction, the transaction is automatically
marked for rollback when the exception is thrown.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newEntityExistsExceptionexception withnullas its detail message.EntityExistsException(String message) Constructs a newEntityExistsExceptionexception with the specified detail message.EntityExistsException(String message, Throwable cause) Constructs a newEntityExistsExceptionexception with the specified detail message and cause.EntityExistsException(Throwable cause) Constructs a newEntityExistsExceptionexception with the specified cause. -
Method Summary
Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
EntityExistsException
public EntityExistsException()Constructs a newEntityExistsExceptionexception withnullas its detail message. -
EntityExistsException
Constructs a newEntityExistsExceptionexception with the specified detail message.- Parameters:
message- the detail message.
-
EntityExistsException
-
EntityExistsException
Constructs a newEntityExistsExceptionexception with the specified cause.- Parameters:
cause- the cause.
-