Browse Source

去掉指定字段的insert

4.0
郑根木 2 years ago
parent
commit
5088a26c75
1 changed files with 4 additions and 26 deletions
  1. +4
    -26
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java

+ 4
- 26
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java View File

@@ -139,40 +139,18 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
* 批量插入单行数据
*
* @param entities PO对象列表
* @return 更新数量
*/
public int[] batchInsertEntity(Collection<T> entities) {
return batchInsertEntity(entities, null);
}


/**
* 批量插入单行数据
*
* @param entities PO对象列表
* @param fields 逗号分隔的字段列表
* @return 更新数量
*/
public int[] batchInsertEntity(Collection<T> entities, String fields) {
public int[] batchInsertEntity(Collection<T> entities) {
StringBuilder sql = new StringBuilder();

sql.append("insert into ").append(modelTable.getSchemaTableName()).append("(");

List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value);
List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size());

if (listFields == null) {
for (EntityColumn column : this.columns.values()) {
sql.append(column.getField().getName()).append(",");
insertColumns.add(column);
}
} else {

for (String name : listFields) {
EntityColumn column = this.columns.get(name.trim());
sql.append(column.getField().getName()).append(",");
insertColumns.add(column);
}
for (EntityColumn column : this.columns.values()) {
sql.append(column.getField().getName()).append(",");
insertColumns.add(column);
}

sql.setCharAt(sql.length() - 1, ')');


Loading…
Cancel
Save