|
@@ -139,40 +139,18 @@ public class EntityDao<T> extends AbstractEntityDao<T> { |
|
|
* 批量插入单行数据 |
|
|
* 批量插入单行数据 |
|
|
* |
|
|
* |
|
|
* @param entities PO对象列表 |
|
|
* @param entities PO对象列表 |
|
|
* @return 更新数量 |
|
|
|
|
|
*/ |
|
|
|
|
|
public int[] batchInsertEntity(Collection<T> entities) { |
|
|
|
|
|
return batchInsertEntity(entities, null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 批量插入单行数据 |
|
|
|
|
|
* |
|
|
|
|
|
* @param entities PO对象列表 |
|
|
|
|
|
* @param fields 逗号分隔的字段列表 |
|
|
* @param fields 逗号分隔的字段列表 |
|
|
* @return 更新数量 |
|
|
* @return 更新数量 |
|
|
*/ |
|
|
*/ |
|
|
public int[] batchInsertEntity(Collection<T> entities, String fields) { |
|
|
|
|
|
|
|
|
public int[] batchInsertEntity(Collection<T> entities) { |
|
|
StringBuilder sql = new StringBuilder(); |
|
|
StringBuilder sql = new StringBuilder(); |
|
|
|
|
|
|
|
|
sql.append("insert into ").append(modelTable.getSchemaTableName()).append("("); |
|
|
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()); |
|
|
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, ')'); |
|
|
sql.setCharAt(sql.length() - 1, ')'); |
|
|