diff --git a/src/main/java/com/avaje/ebean/common/BeanMap.java b/src/main/java/com/avaje/ebean/common/BeanMap.java index 74b0aa1bf..33fb635b9 100644 --- a/src/main/java/com/avaje/ebean/common/BeanMap.java +++ b/src/main/java/com/avaje/ebean/common/BeanMap.java @@ -1,15 +1,14 @@ package com.avaje.ebean.common; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - import com.avaje.ebean.bean.BeanCollectionLoader; import com.avaje.ebean.bean.EntityBean; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + /** * Map capable of lazy loading. */ @@ -260,19 +259,19 @@ public final class BeanMap extends AbstractBeanCollection implements Ma } @SuppressWarnings({ "unchecked", "rawtypes" }) - public void putAll(Map t) { + public void putAll(Map puts) { checkReadOnly(); init(); if (modifyListening) { - Iterator it = t.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - Object o = map.put((K) entry.getKey(), (E) entry.getValue()); - modifyAddition((E) entry.getValue()); - modifyRemoval(o); + for (Entry entry : puts.entrySet()) { + Object oldBean = map.put(entry.getKey(), entry.getValue()); + if (entry.getValue() != oldBean) { + modifyAddition(entry.getValue()); + modifyRemoval(oldBean); + } } } - map.putAll(t); + map.putAll(puts); } public E remove(Object key) {