hhh-6095 flush/lock fix to throw TransactionRequiredException

This commit is contained in:
Scott Marlow 2011-04-13 23:15:06 -04:00
parent 8edc1f1880
commit d24835fdd5
1 changed files with 7 additions and 6 deletions

View File

@ -958,10 +958,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
}
public void flush() {
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
try {
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
getSession().flush();
}
catch ( RuntimeException e ) {
@ -1074,10 +1074,11 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
LockOptions lockOptions = null;
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
try {
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
if ( !contains( entity ) ) {
throw new IllegalArgumentException( "entity not in the persistence context" );
}