#432 - Delete using Query does not commit

This commit is contained in:
Robin Bygrave
2015-10-22 13:29:21 +13:00
parent 0351eab3a7
commit f3102ba02c
8 changed files with 35 additions and 29 deletions
@@ -59,11 +59,6 @@ public class ScopedTransaction implements SpiTransaction {
}
}
@Override
public void endQueryOnly() {
transaction.endQueryOnly();
}
@Override
public String getLogPrefix() {
return transaction.getLogPrefix();
@@ -19,11 +19,6 @@ import com.avaje.ebeaninternal.server.persist.BatchControl;
*/
public interface SpiTransaction extends Transaction {
/**
* End the transaction when had query only use.
*/
void endQueryOnly();
/**
* Return the string prefix with the transactin id and label used in logging.
*/
@@ -1301,6 +1301,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
SpiOrmQueryRequest<T> request = createQueryRequest(Type.DELETE, query, t);
try {
request.initTransIfRequired();
request.markNotQueryOnly();
return request.delete();
} finally {
request.endTransIfRequired();
@@ -72,6 +72,13 @@ public final class OrmQueryRequest<T> extends BeanRequest implements BeanQueryRe
this.readOnly = query.isReadOnly();
}
/**
* Mark the transaction as not being query only.
*/
@Override
public void markNotQueryOnly() {
transaction.markNotQueryOnly();
}
/**
* Return the database platform like clause.
@@ -219,7 +226,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements BeanQueryRe
*/
public void endTransIfRequired() {
if (createdTransaction) {
transaction.endQueryOnly();
transaction.commit();
}
}
@@ -59,7 +59,7 @@ public final class RelationalQueryRequest {
*/
public void endTransIfRequired() {
if (createdTransaction) {
trans.endQueryOnly();
trans.commit();
}
}
@@ -112,4 +112,8 @@ public interface SpiOrmQueryRequest<T> {
*/
String getDBLikeClause();
/**
* Mark the underlying transaction as not being query only.
*/
void markNotQueryOnly();
}
@@ -849,23 +849,6 @@ public class JdbcTransaction implements SpiTransaction {
connection.commit();
}
/**
* End the transaction on a query only request.
*/
@Override
public void endQueryOnly() {
if (!isActive()) {
throw new IllegalStateException(illegalStateMessage);
}
try {
connectionEndForQueryOnly();
} finally {
// these will not throw an exception
deactivate();
notifyQueryOnly();
}
}
/**
* Commit the transaction.
*/