This commit is contained in:
@@ -313,6 +313,18 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
||||
@Override
|
||||
public <T> void insert(T... values) {
|
||||
if (values.length == 0) return;
|
||||
if (values.length > 1) { //检查对象是否都是同一个Entity类
|
||||
Class clazz = null;
|
||||
for (T val : values) {
|
||||
if (clazz == null) {
|
||||
clazz = val.getClass();
|
||||
continue;
|
||||
}
|
||||
if (clazz != val.getClass()) {
|
||||
throw new RuntimeException("DataSource.insert must the same Class Entity, but diff is " + clazz + " and " + val.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
final EntityInfo<T> info = loadEntityInfo((Class<T>) values[0].getClass());
|
||||
if (info.isVirtualEntity()) {
|
||||
insert(null, info, values);
|
||||
@@ -465,6 +477,18 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
||||
@Override
|
||||
public <T> int delete(T... values) {
|
||||
if (values.length == 0) return -1;
|
||||
if (values.length > 1) { //检查对象是否都是同一个Entity类
|
||||
Class clazz = null;
|
||||
for (T val : values) {
|
||||
if (clazz == null) {
|
||||
clazz = val.getClass();
|
||||
continue;
|
||||
}
|
||||
if (clazz != val.getClass()) {
|
||||
throw new RuntimeException("DataSource.delete must the same Class Entity, but diff is " + clazz + " and " + val.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
final EntityInfo<T> info = loadEntityInfo((Class<T>) values[0].getClass());
|
||||
if (info.isVirtualEntity()) { //虚拟表只更新缓存Cache
|
||||
return delete(null, info, values);
|
||||
@@ -625,6 +649,18 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
||||
@Override
|
||||
public <T> int update(T... values) {
|
||||
if (values.length == 0) return 0;
|
||||
if (values.length > 1) { //检查对象是否都是同一个Entity类
|
||||
Class clazz = null;
|
||||
for (T val : values) {
|
||||
if (clazz == null) {
|
||||
clazz = val.getClass();
|
||||
continue;
|
||||
}
|
||||
if (clazz != val.getClass()) {
|
||||
throw new RuntimeException("DataSource.update must the same Class Entity, but diff is " + clazz + " and " + val.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
final EntityInfo<T> info = loadEntityInfo((Class<T>) values[0].getClass());
|
||||
if (info.isVirtualEntity()) {
|
||||
return update(null, info, values);
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface DataSource {
|
||||
|
||||
//----------------------insert-----------------------------
|
||||
/**
|
||||
* 新增记录, 必须是Entity对象 <br>
|
||||
* 新增记录, 多对象必须是同一个Entity类 <br>
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param values Entity对象
|
||||
@@ -34,7 +34,7 @@ public interface DataSource {
|
||||
|
||||
//-------------------------delete--------------------------
|
||||
/**
|
||||
* 删除指定主键值的记录, 必须是Entity对象 <br>
|
||||
* 删除指定主键值的记录, 多对象必须是同一个Entity类 <br>
|
||||
* 等价SQL: DELETE FROM {table} WHERE {primary} IN {values.id} <br>
|
||||
*
|
||||
* @param <T> 泛型
|
||||
@@ -84,7 +84,7 @@ public interface DataSource {
|
||||
|
||||
//------------------------update---------------------------
|
||||
/**
|
||||
* 更新记录, 必须是Entity对象 <br>
|
||||
* 更新记录, 多对象必须是同一个Entity类 <br>
|
||||
* 等价SQL: <br>
|
||||
* UPDATE {table} SET column1 = value1, column2 = value2, ··· WHERE {primary} = {id1} <br>
|
||||
* UPDATE {table} SET column1 = value1, column2 = value2, ··· WHERE {primary} = {id2} <br>
|
||||
|
||||
Reference in New Issue
Block a user