Add Query.withLock(LockType) and withLock(LockType, LockWait) (#2116)

Add Query.withLock(LockType) and withLock(LockType, LockWait)
This commit is contained in:
Rob Bygrave
2020-12-01 21:31:53 +13:00
committed by GitHub
parent f6c4024ae5
commit c66875449b
8 changed files with 139 additions and 7 deletions
@@ -486,6 +486,16 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return query.filterMany(manyProperty).where(expressions, params);
}
@Override
public Query<T> withLock(Query.LockType lockType) {
return query.withLock(lockType);
}
@Override
public Query<T> withLock(Query.LockType lockType, Query.LockWait lockWait) {
return query.withLock(lockType, lockWait);
}
@Override
public Query<T> forUpdate() {
return query.forUpdate();
@@ -491,6 +491,16 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
return exprList.findOneOrEmpty();
}
@Override
public Query<T> withLock(Query.LockType lockType) {
return exprList.withLock(lockType);
}
@Override
public Query<T> withLock(Query.LockType lockType, Query.LockWait lockWait) {
return exprList.withLock(lockType, lockWait);
}
@Override
public Query<T> forUpdate() {
return exprList.forUpdate();
@@ -544,6 +544,16 @@ class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T> {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> withLock(LockType lockType) {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> withLock(LockType lockType, LockWait lockWait) {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
}
@Override
public Query<T> forUpdate() {
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
@@ -963,6 +963,16 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return this;
}
@Override
public Query<T> withLock(LockType lockType) {
return setForUpdateWithMode(LockWait.WAIT, lockType);
}
@Override
public Query<T> withLock(LockType lockType, LockWait lockWait) {
return setForUpdateWithMode(lockWait, lockType);
}
@Override
public DefaultOrmQuery<T> forUpdate() {
return setForUpdateWithMode(LockWait.WAIT, LockType.DEFAULT);