mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
rename BaseMapper.insertBatchWithFirstEntityColumns to insertBatch
This commit is contained in:
parent
b75699e73e
commit
05aad515d2
@ -46,10 +46,11 @@ public interface BaseMapper<T> {
|
||||
*
|
||||
* @param entities 插入的数据列表
|
||||
* @return 返回影响的行数
|
||||
* @see com.mybatisflex.core.provider.EntitySqlProvider#insertBatchWithFirstEntityColumns(Map, ProviderContext)
|
||||
* @see com.mybatisflex.core.provider.EntitySqlProvider#insertBatch(Map, ProviderContext)
|
||||
* @see com.mybatisflex.core.FlexConsts#METHOD_INSERT_BATCH
|
||||
*/
|
||||
@InsertProvider(type = EntitySqlProvider.class, method = "insertBatchWithFirstEntityColumns")
|
||||
int insertBatchWithFirstEntityColumns(@Param(FlexConsts.ENTITIES) List<T> entities);
|
||||
@InsertProvider(type = EntitySqlProvider.class, method = FlexConsts.METHOD_INSERT_BATCH)
|
||||
int insertBatch(@Param(FlexConsts.ENTITIES) List<T> entities);
|
||||
|
||||
/**
|
||||
* 根据 id 删除数据
|
||||
|
||||
@ -36,4 +36,6 @@ public class FlexConsts {
|
||||
public static final String ENTITY = "$$entity";
|
||||
public static final String ENTITIES = "$$entities";
|
||||
public static final String IGNORE_NULLS = "$$ignoreNulls";
|
||||
|
||||
public static final String METHOD_INSERT_BATCH = "insertBatch";
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ public class CommonsDialectImpl implements IDialect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String forInsertBatchWithFirstEntityColumns(TableInfo tableInfo, List<Object> entities) {
|
||||
public String forInsertEntityBatch(TableInfo tableInfo, List<Object> entities) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("INSERT INTO ").append(wrap(tableInfo.getTableName()));
|
||||
String[] insertColumns = tableInfo.obtainInsertColumns();
|
||||
|
||||
@ -61,7 +61,7 @@ public interface IDialect {
|
||||
//////for entity /////
|
||||
String forInsertEntity(TableInfo tableInfo, Object entity);
|
||||
|
||||
String forInsertBatchWithFirstEntityColumns(TableInfo tableInfo, List<Object> entities);
|
||||
String forInsertEntityBatch(TableInfo tableInfo, List<Object> entities);
|
||||
|
||||
String forDeleteEntityById(TableInfo tableInfo);
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ public class FlexConfiguration extends Configuration {
|
||||
ms = replaceRowKeyGenerator(ms);
|
||||
}
|
||||
//entity insert methods
|
||||
else if (StringUtil.endsWithAny(ms.getId(), "insert", "insertBatchWithFirstEntityColumns")
|
||||
else if (StringUtil.endsWithAny(ms.getId(), "insert", FlexConsts.METHOD_INSERT_BATCH)
|
||||
&& ms.getKeyGenerator() == NoKeyGenerator.INSTANCE) {
|
||||
ms = replaceEntityKeyGenerator(ms);
|
||||
}
|
||||
@ -208,7 +208,7 @@ public class FlexConfiguration extends Configuration {
|
||||
}
|
||||
|
||||
//批量插入
|
||||
if (ms.getId().endsWith("insertBatchWithFirstEntityColumns")) {
|
||||
if (ms.getId().endsWith(FlexConsts.METHOD_INSERT_BATCH)) {
|
||||
keyGenerator = new MultiEntityKeyGenerator(keyGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -68,9 +68,10 @@ public class EntitySqlProvider {
|
||||
* @param params
|
||||
* @param context
|
||||
* @return sql
|
||||
* @see com.mybatisflex.core.BaseMapper#insertBatchWithFirstEntityColumns(List)
|
||||
* @see com.mybatisflex.core.BaseMapper#insertBatch(List)
|
||||
* @see com.mybatisflex.core.FlexConsts#METHOD_INSERT_BATCH
|
||||
*/
|
||||
public static String insertBatchWithFirstEntityColumns(Map params, ProviderContext context) {
|
||||
public static String insertBatch(Map params, ProviderContext context) {
|
||||
List<Object> entities = ProviderUtil.getEntities(params);
|
||||
if (CollectionUtil.isEmpty(entities)) {
|
||||
throw FlexExceptions.wrap("entities can not be null or empty.");
|
||||
@ -84,7 +85,7 @@ public class EntitySqlProvider {
|
||||
|
||||
ProviderUtil.setSqlArgs(params, values);
|
||||
|
||||
return DialectFactory.getDialect().forInsertBatchWithFirstEntityColumns(tableInfo, entities);
|
||||
return DialectFactory.getDialect().forInsertEntityBatch(tableInfo, entities);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user