DataSource.updateColumn系列方法屏蔽掉limit功能

This commit is contained in:
Redkale
2017-12-28 10:16:21 +08:00
parent 1d640f943a
commit ef9eaa0a66
2 changed files with 15 additions and 7 deletions

View File

@@ -109,27 +109,33 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC
} }
@Override @Override
@Local
public void close() throws Exception { public void close() throws Exception {
readPool.close(); readPool.close();
writePool.close(); writePool.close();
} }
@Local
public PoolJdbcSource getReadPoolJdbcSource() { public PoolJdbcSource getReadPoolJdbcSource() {
return readPool; return readPool;
} }
@Local
public PoolJdbcSource getWritePoolJdbcSource() { public PoolJdbcSource getWritePoolJdbcSource() {
return writePool; return writePool;
} }
@Local
public Connection createReadSQLConnection() { public Connection createReadSQLConnection() {
return readPool.poll(); return readPool.poll();
} }
@Local
public <T> Connection createWriteSQLConnection() { public <T> Connection createWriteSQLConnection() {
return writePool.poll(); return writePool.poll();
} }
@Local
public void closeSQLConnection(final Connection sqlconn) { public void closeSQLConnection(final Connection sqlconn) {
if (sqlconn == null) return; if (sqlconn == null) return;
try { try {
@@ -140,6 +146,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC
} }
@Override @Override
@Local
public EntityInfo apply(Class t) { public EntityInfo apply(Class t) {
return loadEntityInfo(t); return loadEntityInfo(t);
} }
@@ -972,9 +979,8 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC
} }
String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + setsql String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + setsql
+ ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2))
: (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2))))
//注LIMIT 仅支持MySQL 且在多表关联式会异常, 该BUG尚未解决 + info.createSQLOrderby(flipper);
sql += info.createSQLOrderby(flipper) + ((flipper == null || flipper.getLimit() < 1) ? "" : (" LIMIT " + flipper.getLimit()));
if (info.isLoggable(logger, Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql); if (info.isLoggable(logger, Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
conn.setReadOnly(false); conn.setReadOnly(false);
if (blobs != null) { if (blobs != null) {
@@ -2369,7 +2375,8 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC
* *
* @return 结果数组 * @return 结果数组
*/ */
public final int[] directExecute(String... sqls) { @Local
public int[] directExecute(String... sqls) {
Connection conn = createWriteSQLConnection(); Connection conn = createWriteSQLConnection();
try { try {
return directExecute(conn, sqls); return directExecute(conn, sqls);
@@ -2385,7 +2392,8 @@ public class DataJdbcSource extends AbstractService implements DataSource, DataC
* @param sql SQL语句 * @param sql SQL语句
* @param consumer 回调函数 * @param consumer 回调函数
*/ */
public final void directQuery(String sql, Consumer<ResultSet> consumer) { @Local
public void directQuery(String sql, Consumer<ResultSet> consumer) {
final Connection conn = createReadSQLConnection(); final Connection conn = createReadSQLConnection();
try { try {
if (logger.isLoggable(Level.FINEST)) logger.finest("direct query sql=" + sql); if (logger.isLoggable(Level.FINEST)) logger.finest("direct query sql=" + sql);

View File

@@ -300,7 +300,7 @@ public interface DataSource {
* 更新符合过滤条件的记录的指定字段 <br> * 更新符合过滤条件的记录的指定字段 <br>
* Flipper中offset字段将被忽略 <br> * Flipper中offset字段将被忽略 <br>
* <b>注意</b>Entity类中标记为&#064;Column(updatable=false)不会被更新 <br> * <b>注意</b>Entity类中标记为&#064;Column(updatable=false)不会被更新 <br>
* 等价SQL: UPDATE {table} SET {column1} = {value1}, {column2} += {value2}, {column3} *= {value3}, &#183;&#183;&#183; WHERE {filter node} ORDER BY {flipper.sort} LIMIT {flipper.limit} <br> * 等价SQL: UPDATE {table} SET {column1} = {value1}, {column2} += {value2}, {column3} *= {value3}, &#183;&#183;&#183; WHERE {filter node} ORDER BY {flipper.sort} <br>
* *
* @param <T> Entity泛型 * @param <T> Entity泛型
* @param clazz Entity类 * @param clazz Entity类
@@ -316,7 +316,7 @@ public interface DataSource {
* 更新符合过滤条件的记录的指定字段 <br> * 更新符合过滤条件的记录的指定字段 <br>
* Flipper中offset字段将被忽略 <br> * Flipper中offset字段将被忽略 <br>
* <b>注意</b>Entity类中标记为&#064;Column(updatable=false)不会被更新 <br> * <b>注意</b>Entity类中标记为&#064;Column(updatable=false)不会被更新 <br>
* 等价SQL: UPDATE {table} SET {column1} = {value1}, {column2} += {value2}, {column3} *= {value3}, &#183;&#183;&#183; WHERE {filter node} ORDER BY {flipper.sort} LIMIT {flipper.limit} <br> * 等价SQL: UPDATE {table} SET {column1} = {value1}, {column2} += {value2}, {column3} *= {value3}, &#183;&#183;&#183; WHERE {filter node} ORDER BY {flipper.sort} <br>
* *
* @param <T> Entity泛型 * @param <T> Entity泛型
* @param clazz Entity类 * @param clazz Entity类