mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#991 ENH: Add forUpdateNoWait() and forUpdateSkipLocked() options ... #528 ENH: Improve exception handling
This commit is contained in:
@@ -206,9 +206,9 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
private Boolean autoTune;
|
||||
|
||||
/**
|
||||
* Allow to fetch a record "for update" which should lock it on read
|
||||
* For update mode.
|
||||
*/
|
||||
private boolean forUpdate;
|
||||
private ForUpdate forUpdate;
|
||||
|
||||
private boolean singleAttribute;
|
||||
|
||||
@@ -579,7 +579,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
// includes joins and we use - delete ... where id in (...)
|
||||
maxRows = 0;
|
||||
firstRow = 0;
|
||||
forUpdate = false;
|
||||
forUpdate = null;
|
||||
rootTableAlias = "${RTA}"; // alias we remove later
|
||||
setSelectId();
|
||||
}
|
||||
@@ -791,11 +791,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return autoTune;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultRawSqlIfRequired() {
|
||||
if (beanDescriptor.isRawSqlBased() && rawSql == null) {
|
||||
@@ -811,11 +806,42 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> setForUpdate(boolean forUpdate) {
|
||||
this.forUpdate = forUpdate;
|
||||
this.forUpdate = (forUpdate) ? ForUpdate.BASE : null;
|
||||
this.excludeBeanCache = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdate() {
|
||||
return setForUpdateWithMode(ForUpdate.BASE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdateNoWait() {
|
||||
return setForUpdateWithMode(ForUpdate.NOWAIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> forUpdateSkipLocked() {
|
||||
return setForUpdateWithMode(ForUpdate.SKIPLOCKED);
|
||||
}
|
||||
|
||||
private DefaultOrmQuery<T> setForUpdateWithMode(ForUpdate mode) {
|
||||
this.forUpdate = mode;
|
||||
this.excludeBeanCache = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForUpdate getForUpdateMode() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfilingListener getProfilingListener() {
|
||||
return profilingListener;
|
||||
|
||||
Reference in New Issue
Block a user