HHH-8541 - EntityManager#getLockMode should technically throw TransactionRequiredException if transaction is not active

This commit is contained in:
Steve Ebersole 2013-09-22 15:36:21 -05:00
parent b839720cd3
commit ccd1fb07c8
1 changed files with 5 additions and 0 deletions

View File

@ -1295,9 +1295,14 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public LockModeType getLockMode(Object entity) {
checkOpen();
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "Call to EntityManager#getLockMode should occur within transaction according to spec" );
}
if ( !contains( entity ) ) {
throw convert (new IllegalArgumentException( "entity not in the persistence context" ) );
}
return getLockModeType( internalGetSession().getCurrentLockMode( entity ) );
}