#398 - ENH: Support delete using a Query instance

This commit is contained in:
Robin Bygrave
2015-08-29 00:58:47 +12:00
parent ccba5d08ef
commit 1c23720605
21 changed files with 407 additions and 24 deletions
@@ -53,6 +53,27 @@ public class CQueryEngine {
return queryBuilder.buildQuery(request);
}
public <T> int delete(OrmQueryRequest<T> request) {
CQueryDelete query = queryBuilder.buildDeleteQuery(request);
try {
int rows = query.delete();
if (request.isLogSql()) {
String logSql = query.getGeneratedSql();
if (TransactionManager.SQL_LOGGER.isTraceEnabled()) {
logSql = Str.add(logSql, "; --bind(", query.getBindLog(), ") rows:", String.valueOf(rows));
}
request.logSql(logSql);
}
return rows;
} catch (SQLException e) {
throw CQuery.createPersistenceException(e, request.getTransaction(), query.getBindLog(), query.getGeneratedSql());
}
}
/**
* Build and execute the find Id's query.
*/