Java List.add() UnsupportedOperationException

八年前。

Java List.add() UnsupportedOperationException

______
Not every List implementation supports the add() method.
One common example is the List returned by Arrays.asList(): it is documented not to support any structural modification (i.e. removing or adding elements) (emphasis mine):
Returns a fixed-size list backed by the specified array.
Even if that’s not the specific List you’re trying to modify, the answer still applies to other Listimplementations that are either immutable or only allow some selected changes.
You can find out about this by reading the documentation of UnsupportedOperationException and List.add(), which documents this to be an “(optional operation)”. The precise meaning of this phrase is explained at the top of the List documentation.
As a workaround you can create a copy of the list to a known-modifiable implementation like ArrayList:
seeAlso = new ArrayList<>(seeAlso);

https://stackoverflow.com/questions/5755477/java-list-add-unsupportedoperationexception

笔记

MyBatis 批量 update,字段不能为 null

MyBatis Batch Update Exception: Column cannot be null

https://stackoverflow.com/questions/32217568/mybatis-batch-update-exceptioncolumn-cannot-be-null

加一句 else

为什么加

UPDATE base\_goods\_package WHEN goodsId = #{item.goodsId} THEN #{item.packageRate} WHEN goodsId = #{item.goodsId} THEN #{item.packageName} WHEN goodsId = #{item.goodsId} THEN #{item.boxLong} WHEN goodsId = #{item.goodsId} THEN #{item.boxWidth} WHEN goodsId = #{item.goodsId} THEN #{item.boxHeight} WHEN goodsId = #{item.goodsId} THEN #{item.boxWeight} WHERE goodsId = #{item.goodsId}

我错了:
参数类型为非字符串类型的时候
上面像我这样写,假如costPrice是Integer,就完蛋了。
要么 item.costPrice.toString(),要么直接删掉写成
这样。

笔记