The JPA specification defines the following exception types:
EntityExistsException
Thrown by the persistence provider when
EntityManager#persist(Object)
is called and
the entity already exists. The current transaction, if one is
active, will be marked for rollback.
EntityNotFoundException
Thrown by the persistence provider when an entity reference
obtained by
EntityManager#getReference(Class,Object)
is
accessed but the entity does not exist. Also thrown when
EntityManager#refresh(Object)
is called and
the object no longer exists in the database. The current
transaction, if one is active, will be marked for rollback.
OptimisticLockException
Thrown by the persistence provider when an optimistic locking conflict occurs. This exception may be thrown as part of an API call, a flush or at commit time. The current transaction, if one is active, will be marked for rollback.
NonUniqueException
Thrown by the persistence provider when
Query#getSingleResult()
is executed on a
query and there is more than one result from the query. This
exception will not cause the current transaction, if one is active,
to be marked for roll back.
NoResultException
Thrown by the persistence provider when
Query#getSingleResult()
is executed on a
query and there is no result to return. This exception will not
cause the current transaction, if one is active, to be marked for
roll back.
In all cases these methods are called internally by JPA Objects, and will be trapped and handled as necessary, with exceptions converted into Object store exceptions to be handled by the Naked Objects framework itself.
TODO: further tests may be required to verify correct behaviour in all these cases.