1. 根据列表批量修改
void secretKeySequence(@Param("list")List<IndustrialShareDto> list);
<update id="secretKeySequence">
update cloud_industrial_set
set `index` =
case
<foreach collection="list" item="item">
when id = #{item.id} then #{item.index}
</foreach>
end
where id in(
<foreach collection="list" item="item" separator=",">
#{item.id}
</foreach>
)
</update>
2. 小于号的处理
select username from t where id <![CDATA[ <= ]]> #{id}
3. 大小写重复列的问题
出现在 3.0.5 版本独有的问题,当返回值是 resultType = java.util.Map
时,会有两个列
<select id="findDataShowSet" resultType="java.util.Map">
select sqltext,customid
from datashowset
where showname = #{showName}
order by id
offset 0 rows fetch next 1 rows only
</select>
protected void loadMappedAndUnmappedColumnNames(ResultSet rs, ResultMap resultMap, List<String> mappedColumnNames, List<String> unmappedColumnNames) throws SQLException {
mappedColumnNames.clear();
unmappedColumnNames.clear();
final ResultSetMetaData rsmd = rs.getMetaData();
final int columnCount = rsmd.getColumnCount();
final Set<String> mappedColumns = resultMap.getMappedColumns();
for (int i = 1; i <= columnCount; i++) {
final String columnName = configuration.isUseColumnLabel() ? rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
//获取大写
final String upperColumnName = columnName.toUpperCase(Locale.ENGLISH);
//大写小写都存了一遍
if (mappedColumns.contains(upperColumnName)) {
mappedColumnNames.add(upperColumnName);
mappedColumnNames.add(columnName);
} else {
unmappedColumnNames.add(upperColumnName);
unmappedColumnNames.add(columnName);
}
}
}
要么换版本,要么手动去掉
Set<String> upperKeys = new HashSet<>();
dataList.forEach(map -> {
upperKeys.addAll(map.keySet());
});
dataList.forEach(
map -> {
for(String key : upperKeys){
map.remove(key.toUpperCase(Locale.ENGLISH));
}
}
);
标签:map,upperKeys,记录,final,item,Mybatis,where,id
From: https://www.cnblogs.com/cnff/p/18043546