There are multiple exceptions are thrown from EJB/JPA API. Some of them cause
transaction to be rolled back and some of them are not.
Exceptions
Persistence Exception
Thrown by the persistence provider when a problem occurs.It may be thrown to report that the invoked operation could not complete because of an unexpected error (e.g. failure of the persistence provider to open a database connection).
Transaction rollback depends on child exception.
Transaction Required Exception
Thrown by the persistence provider when a transaction is required but is not active.Optimistic Lock Exception
Thrown by the persistence provider when an optimistic locking conflict occurs.This exception may be thrown as part of an API call, at flush, or at commit time.
Rollback active Transaction.
Rollback Exception
Thrown by the persistence provider when Entity Transaction Commit fails.Rollback active Transaction.
Entity Exists Exception
Thrown by the persistence provider at the time of persist operation invocation, and the entity already exists.May be thrown when persist operation is invoked, or the
EntityExistsException
or another
PersistenceException
may be thrown at commit time.
Rollback active Transaction.
Entity Not Found Exception
Thrown by the persistence provider when an entity reference obtained bygetReference
is
accessed but the entity does not exist. It is also thrown by the refresh operation when the entity no longer exists in the database.
Rollback active Transaction.
No Result Exception
Thrown by the persistence provider whenQuery.getSingleResult
is invoked and there is no result
to return.
Does not rollback Transaction.
Non Unique Result Exception
Thrown by the persistence provider whenQuery.getSingleResult
is invoked and there is more than
one result from the query.
Does not rollback Transaction.
Post a Comment
Post a Comment