HHH-8541 - EntityManager#getLockMode should technically throw TransactionRequiredException if transaction is not active
This commit is contained in:
parent
b839720cd3
commit
ccd1fb07c8
|
@ -1295,9 +1295,14 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
public LockModeType getLockMode(Object entity) {
|
public LockModeType getLockMode(Object entity) {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
|
|
||||||
|
if ( !isTransactionInProgress() ) {
|
||||||
|
throw new TransactionRequiredException( "Call to EntityManager#getLockMode should occur within transaction according to spec" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !contains( entity ) ) {
|
if ( !contains( entity ) ) {
|
||||||
throw convert (new IllegalArgumentException( "entity not in the persistence context" ) );
|
throw convert (new IllegalArgumentException( "entity not in the persistence context" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return getLockModeType( internalGetSession().getCurrentLockMode( entity ) );
|
return getLockModeType( internalGetSession().getCurrentLockMode( entity ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue