This commit is contained in:
Redkale
2018-05-02 20:46:38 +08:00
parent fb3dd6049d
commit f712107fb8

View File

@@ -230,7 +230,9 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
continue; continue;
} }
if (clazz != val.getClass()) { if (clazz != val.getClass()) {
throw new RuntimeException("DataSource.insert must the same Class Entity, but diff is " + clazz + " and " + val.getClass()); CompletableFuture<Void> future = new CompletableFuture<>();
future.completeExceptionally(new SQLException("DataSource.insert must the same Class Entity, but diff is " + clazz + " and " + val.getClass()));
return future;
} }
} }
} }
@@ -305,13 +307,13 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
if (values.length == 0) return CompletableFuture.completedFuture(-1); if (values.length == 0) return CompletableFuture.completedFuture(-1);
if (values.length > 1) { //检查对象是否都是同一个Entity类 if (values.length > 1) { //检查对象是否都是同一个Entity类
Class clazz = null; Class clazz = null;
CompletableFuture<Integer> future = new CompletableFuture<>();
for (T val : values) { for (T val : values) {
if (clazz == null) { if (clazz == null) {
clazz = val.getClass(); clazz = val.getClass();
continue; continue;
} }
if (clazz != val.getClass()) { if (clazz != val.getClass()) {
CompletableFuture<Integer> future = new CompletableFuture<>();
future.completeExceptionally(new SQLException("DataSource.delete must the same Class Entity, but diff is " + clazz + " and " + val.getClass())); future.completeExceptionally(new SQLException("DataSource.delete must the same Class Entity, but diff is " + clazz + " and " + val.getClass()));
return future; return future;
} }