mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add support for Postgres lock types (no key, share, key share) with FOR UPDATE
This commit is contained in:
+15
@@ -491,16 +491,31 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return query.forUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdate(Query.LockType lockType) {
|
||||
return query.forUpdate(lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateNoWait() {
|
||||
return query.forUpdateNoWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateNoWait(Query.LockType lockType) {
|
||||
return query.forUpdateNoWait(lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateSkipLocked() {
|
||||
return query.forUpdateSkipLocked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateSkipLocked(Query.LockType lockType) {
|
||||
return query.forUpdateSkipLocked(lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> select(String fetchProperties) {
|
||||
return query.select(fetchProperties);
|
||||
|
||||
@@ -559,6 +559,21 @@ class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T> {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdate(LockType lockType) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateNoWait(LockType lockType) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateSkipLocked(LockType lockType) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForUpdate() {
|
||||
return false;
|
||||
@@ -569,6 +584,11 @@ class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T> {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockType getForUpdateLockType() {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> alias(String alias) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
|
||||
@@ -236,10 +236,8 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
*/
|
||||
private Boolean autoTune;
|
||||
|
||||
/**
|
||||
* For update mode.
|
||||
*/
|
||||
private ForUpdate forUpdate;
|
||||
private LockType lockType;
|
||||
|
||||
private boolean singleAttribute;
|
||||
|
||||
@@ -967,21 +965,37 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdate() {
|
||||
return setForUpdateWithMode(ForUpdate.BASE);
|
||||
return setForUpdateWithMode(ForUpdate.BASE, LockType.Default);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdate(LockType lockType) {
|
||||
return setForUpdateWithMode(ForUpdate.BASE, lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateNoWait(LockType lockType) {
|
||||
return setForUpdateWithMode(ForUpdate.NOWAIT, lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> forUpdateSkipLocked(LockType lockType) {
|
||||
return setForUpdateWithMode(ForUpdate.SKIPLOCKED, lockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdateNoWait() {
|
||||
return setForUpdateWithMode(ForUpdate.NOWAIT);
|
||||
return setForUpdateWithMode(ForUpdate.NOWAIT, LockType.Default);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdateSkipLocked() {
|
||||
return setForUpdateWithMode(ForUpdate.SKIPLOCKED);
|
||||
return setForUpdateWithMode(ForUpdate.SKIPLOCKED, LockType.Default);
|
||||
}
|
||||
|
||||
private DefaultOrmQuery<T> setForUpdateWithMode(ForUpdate mode) {
|
||||
private DefaultOrmQuery<T> setForUpdateWithMode(ForUpdate mode, LockType lockType) {
|
||||
this.forUpdate = mode;
|
||||
this.lockType = lockType;
|
||||
this.useBeanCache = CacheMode.OFF;
|
||||
return this;
|
||||
}
|
||||
@@ -996,6 +1010,11 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockType getForUpdateLockType() {
|
||||
return lockType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfilingListener getProfilingListener() {
|
||||
return profilingListener;
|
||||
|
||||
Reference in New Issue
Block a user