HHH-8563 - javax.persistence.Query#getLockMode should throw ISE in some cases

This commit is contained in:
Steve Ebersole 2013-09-26 14:53:22 -05:00
parent 0d7854a15d
commit f79271d60e
1 changed files with 10 additions and 1 deletions

View File

@ -139,7 +139,16 @@ public abstract class AbstractQueryImpl<X> extends BaseQueryImpl implements Type
@Override
public javax.persistence.LockModeType getLockMode() {
getEntityManager().checkOpen( false );
checkOpen( false );
if ( isNativeSqlQuery() ) {
throw new IllegalStateException( "Illegal attempt to set lock mode on a native SQL query" );
}
if ( ! isSelectQuery() ) {
throw new IllegalStateException( "Illegal attempt to set lock mode on a non-SELECT query" );
}
return jpaLockMode;
}