Scott Marlow commented on Bug HHH-7861

JPA 2.0 spec description of EntityNotFoundException

The EntityNotFoundException is thrown by the persistence provider when an entity
reference obtained by getReference is accessed but the entity does not exist. It is thrown
by the refresh operation when the entity no longer exists in the database. It is also thrown
by the lock operation when pessimistic locking is used and the entity no longer exists in the
database. The current transaction, if one is active, will be marked for rollback.

Text describing one of the find methods:

/**

  • Find by primary key and lock, using the specified properties.
  • Search for an entity of the specified class and primary key
  • and lock it with respect to the specified lock type.
  • If the entity instance is contained in the persistence context
  • it is returned from there. If the entity is found
  • within the persistence context and the lock mode type
  • is pessimistic and the entity has a version attribute, the
  • persistence provider must perform optimistic version checks
  • when obtaining the database lock. If these checks fail,
  • the OptimisticLockException will be thrown.
  • If the lock mode type is pessimistic and the entity instance
  • is found but cannot be locked:
  • - the PessimisticLockException will be thrown if the database
    *
    locking failure causes transaction-level rollback
  • - the LockTimeoutException will be thrown if the database
    *
    locking failure causes only statement-level rollback
  • If a vendor-specific property or hint is not recognized,
  • it is silently ignored.
  • Portable applications should not rely on the standard timeout
  • hint. Depending on the database in use and the locking
  • mechanisms used by the provider, the hint may or may not
  • be observed.
  • @param entityClass
  • @param primaryKey
  • @param lockMode
  • @param properties standard and vendor-specific properties
    *
    and hints
  • @return the found entity instance or null if the entity does
    *
    not exist
  • @throws IllegalArgumentException if the first argument does
    *
    not denote an entity type or the second argument is
    *
    not a valid type for that entity's primary key or
    *
    is null
  • @throws TransactionRequiredException if there is no
    *
    transaction and a lock mode other than NONE is
    *
    specified
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira