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

View File

@@ -300,7 +300,7 @@ public interface DataSource {
* 更新符合过滤条件的记录的指定字段 <br>
* Flipper中offset字段将被忽略 <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 clazz Entity类
@@ -316,7 +316,7 @@ public interface DataSource {
* 更新符合过滤条件的记录的指定字段 <br>
* Flipper中offset字段将被忽略 <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 clazz Entity类