#2113 - Refactor rename Query.ForUpdate to Query.LockWait

Slightly improve the name of the enum. Note that although this is on public Query it's only internally used.
This commit is contained in:
rob bygrave
2020-11-25 22:23:17 +13:00
parent 8e91268979
commit 9064e96b90
14 changed files with 57 additions and 54 deletions
+5 -5
View File
@@ -210,13 +210,13 @@ public interface Query<T> {
}
/**
* For update mode.
* FOR UPDATE wait mode.
*/
enum ForUpdate {
enum LockWait {
/**
* Standard For update clause.
*/
BASE,
WAIT,
/**
* For update with No Wait option.
@@ -1685,9 +1685,9 @@ public interface Query<T> {
boolean isForUpdate();
/**
* Return the "for update" mode to use.
* Return the "for update" wait mode to use.
*/
ForUpdate getForUpdateMode();
LockWait getForUpdateLockWait();
/**
* Return the lock type (strength) to use with "for update".
@@ -679,7 +679,7 @@ public class DatabasePlatform {
public String completeSql(String sql, Query<?> query) {
if (query.isForUpdate()) {
sql = withForUpdate(sql, query.getForUpdateMode(), query.getForUpdateLockType());
sql = withForUpdate(sql, query.getForUpdateLockWait(), query.getForUpdateLockType());
}
return sql;
}
@@ -687,12 +687,12 @@ public class DatabasePlatform {
/**
* For update hint on the FROM clause (SQL server only).
*/
public String fromForUpdate(Query.ForUpdate forUpdateMode) {
public String fromForUpdate(Query.LockWait lockWait) {
// return null except for sql server
return null;
}
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// silently assume the database does not support the "for update" clause.
logger.info("it seems your database does not support the 'for update' clause");
return sql;
@@ -51,7 +51,7 @@ public class H2Platform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// NOWAIT and SKIP LOCKED currently not supported with H2
return sql + " for update";
}
@@ -1,7 +1,7 @@
package io.ebean.config.dbplatform.hana;
import io.ebean.Query;
import io.ebean.Query.ForUpdate;
import io.ebean.Query.LockWait;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.config.PlatformConfig;
@@ -69,16 +69,16 @@ public class HanaPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, ForUpdate forUpdateMode, Query.LockType lockType) {
switch (forUpdateMode) {
case BASE:
protected String withForUpdate(String sql, LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case WAIT:
return sql + " for update";
case NOWAIT:
return sql + " for update nowait";
case SKIPLOCKED:
return sql + " for update ignore locked";
default:
throw new IllegalArgumentException("Unknown update mode: " + forUpdateMode.name());
throw new IllegalArgumentException("Unknown update mode: " + lockWait);
}
}
@@ -60,7 +60,7 @@ public abstract class BaseMySqlPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// NOWAIT and SKIP LOCKED currently not supported with MySQL
return sql + " for update";
}
@@ -48,8 +48,8 @@ public class NuoDbPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case NOWAIT:
return sql + " for update nowait";
case SKIPLOCKED:
@@ -79,8 +79,8 @@ public class OraclePlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case SKIPLOCKED:
return sql + " for update skip locked";
case NOWAIT:
@@ -128,8 +128,8 @@ public class PostgresPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case SKIPLOCKED:
return sql + lock(lockType) + SKIP_LOCKED;
case NOWAIT:
@@ -105,8 +105,8 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
* For update is part of the FROM clause on the base table for sql server.
*/
@Override
public String fromForUpdate(Query.ForUpdate forUpdateMode) {
switch (forUpdateMode) {
public String fromForUpdate(Query.LockWait lockWait) {
switch (lockWait) {
case SKIPLOCKED:
return "with (updlock,readpast)";
case NOWAIT:
@@ -117,7 +117,7 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode, Query.LockType lockType) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// for update are hints on from clause of base table
return sql;
}