仕事メモ
先週ほぼ徹夜する羽目になったこのコード。
忘れないようにメモっておこうと思う。
(注)
すいません、これこそ正にJavaの開発者にしかわからないものなので、
興味のない方はスルーしてください。
Collection c = request.getLCollection();
if (c != null && c.size() > 0) {
for (Iterator it = c.iterator(); it.hasNext();) {
L l = (L) it.next();
it.remove();
c.remove();
}
}
c = collection of entity bean of type L
l = entity bean (child bean)
it.remove()をしないと、
c.remove()をした際に
parent beanのcollectionを編集することになり、
ConcurrentModificationExceptionが発生する。
it.remove()をすることによって、
それを回避することができる。