#991 ENH: Add forUpdateNoWait() and forUpdateSkipLocked() options ... #528 ENH: Improve exception handling

This commit is contained in:
Rob Bygrave
2017-03-13 20:50:22 +13:00
parent a3dbd4538f
commit c8d01828b3
49 changed files with 985 additions and 336 deletions
@@ -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;