refresh(entity, lockMode) - JPA EntityManager's method
Method javax.persistence.EntityManager
void refresh(
Object entity,
LockModeType lockMode
)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type.
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.
- Parameters:
-
entity
- entity instancelockMode
- lock mode
- Throws:
-
IllegalArgumentException
- if the instance is not an entity or the entity is not managed- TransactionRequiredException - if there is no transaction and if invoked on a container-managed
EntityManager
instance withPersistenceContextType.TRANSACTION
or with a lock mode other thanNONE
- EntityNotFoundException - if the entity no longer exists in the database
- PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
- LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
- PersistenceException - if an unsupported lock call is made
- TransactionRequiredException - if there is no transaction and if invoked on a container-managed
- Since:
- JPA 2.0