From 0df9a940c5b6cad62a6a67c82df745407d3d6ee4 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Sat, 24 Jun 2017 16:24:13 +0800 Subject: [PATCH] --- src/org/redkale/source/DataJdbcSource.java | 14 +++++++------- src/org/redkale/source/DataSource.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/org/redkale/source/DataJdbcSource.java b/src/org/redkale/source/DataJdbcSource.java index c652e16f9..39a309fbc 100644 --- a/src/org/redkale/source/DataJdbcSource.java +++ b/src/org/redkale/source/DataJdbcSource.java @@ -447,7 +447,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi } String sql = "DELETE " + (this.readPool.isMysql() ? "a" : "") + " FROM " + info.getTable(node) + " a" + (join1 == null ? "" : (", " + join1)) + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) - : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))) + info.createSQLOrderby(flipper) + : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))) + info.createSQLOrderby(flipper) + ((flipper == null || flipper.getLimit() < 1) ? "" : (" LIMIT " + flipper.getLimit())); if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(info.getType().getSimpleName() + " delete sql=" + sql); conn.setReadOnly(false); @@ -613,7 +613,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi } @Override - public CompletableFuture updateColumnupdateColumnAsync(final Class clazz, final Serializable id, final String column, final Serializable value) { + public CompletableFuture updateColumnAsync(final Class clazz, final Serializable id, final String column, final Serializable value) { return CompletableFuture.supplyAsync(() -> updateColumn(clazz, id, column, value), getExecutor()); } @@ -703,7 +703,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + info.getSQLColumn("a", column) + " = ?" + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) - : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); + : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql); conn.setReadOnly(false); Blob blob = conn.createBlob(); @@ -716,7 +716,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + info.getSQLColumn("a", column) + " = " + info.formatToString(value) + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) - : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); + : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql); conn.setReadOnly(false); final Statement stmt = conn.createStatement(); @@ -776,7 +776,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi List blobs = null; for (ColumnValue col : values) { Attribute attr = info.getUpdateAttribute(col.getColumn()); - if (attr == null) continue; + if (attr == null) throw new RuntimeException(info.getType() + " cannot found column " + col.getColumn()); attrs.add(attr); cols.add(col); if (!virtual) { @@ -921,7 +921,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi } String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + setsql + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) - : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); + : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); //注:LIMIT 仅支持MySQL 且在多表关联式会异常, 该BUG尚未解决 sql += info.createSQLOrderby(flipper) + ((flipper == null || flipper.getLimit() < 1) ? "" : (" LIMIT " + flipper.getLimit())); if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql); @@ -1107,7 +1107,7 @@ public class DataJdbcSource extends AbstractService implements DataSource, Servi } String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) + " SET " + setsql + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) - : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); + : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(info.getType().getSimpleName() + " update sql=" + sql); conn.setReadOnly(false); if (blobs != null) { diff --git a/src/org/redkale/source/DataSource.java b/src/org/redkale/source/DataSource.java index b679929e6..d133effe4 100644 --- a/src/org/redkale/source/DataSource.java +++ b/src/org/redkale/source/DataSource.java @@ -198,7 +198,7 @@ public interface DataSource { * * @return 影响的记录条数CompletableFuture */ - public CompletableFuture updateColumnupdateColumnAsync(final Class clazz, final Serializable id, final String column, final Serializable value); + public CompletableFuture updateColumnAsync(final Class clazz, final Serializable id, final String column, final Serializable value); /** * 更新符合过滤条件记录的单个字段