JPA requires that IllegalStateException be thrown instead of UOE

This commit is contained in:
Christian Beikov 2022-11-10 14:51:41 +01:00
parent 7a335393c7
commit 61421d5d54
1 changed files with 8 additions and 3 deletions

View File

@ -1083,17 +1083,22 @@ public class ProcedureCallImpl<R>
@Override @Override
public QueryImplementor<R> setLockMode(String alias, LockMode lockMode) { public QueryImplementor<R> setLockMode(String alias, LockMode lockMode) {
throw new UnsupportedOperationException( "setLockMode does not apply to procedure calls" ); // throw IllegalStateException here for consistency with JPA
throw new IllegalStateException( "Illegal attempt to set lock mode for a procedure calls" );
} }
@Override @Override
public ProcedureCallImplementor<R> setLockMode(LockModeType lockMode) { public ProcedureCallImplementor<R> setLockMode(LockModeType lockMode) {
throw new UnsupportedOperationException( "setLockMode does not apply to procedure calls" ); // the JPA spec requires IllegalStateException here, even
// though it's logically an UnsupportedOperationException
throw new IllegalStateException( "Illegal attempt to set lock mode for a procedure calls" );
} }
@Override @Override
public LockModeType getLockMode() { public LockModeType getLockMode() {
throw new UnsupportedOperationException( "getLockMode does not apply to procedure calls" ); // the JPA spec requires IllegalStateException here, even
// though it's logically an UnsupportedOperationException
throw new IllegalStateException( "Illegal attempt to get lock mode on a native-query" );
} }
@Override @Override