On lazy load too many events are fired to the PropertyChangeListener.
Index: core/src/main/java/com/avaje/ebean/server/core/RefreshHelp.java===================================================================--- core/src/main/java/com/avaje/ebean/server/core/RefreshHelp.java (revision 398)+++ core/src/main/java/com/avaje/ebean/server/core/RefreshHelp.java Wed Aug 26 15:58:38 CEST 2009@@ -92,7 +92,12 @@ } else { Object dbVal = prop.getValue(dbBean);+ if (isLazyLoad) {+ prop.setValue(o, dbVal);+ }+ else {- prop.setValueIntercept(o, dbVal);+ prop.setValueIntercept(o, dbVal);+ } if (setOriginalOldValues){ // maintain original oldValues for partially loaded bean@@ -109,8 +114,13 @@ } else { Object dbVal = prop.getValue(dbBean);+ if (isLazyLoad) {+ prop.setValue(o, dbVal);+ }+ else {- prop.setValueIntercept(o, dbVal);+ prop.setValueIntercept(o, dbVal);+ }- + if (setOriginalOldValues){ // maintain original oldValues for partially loaded bean prop.setValue(originalOldValues, dbVal);Index: core/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java===================================================================--- core/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java (revision 383)+++ core/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java Wed Aug 26 15:59:39 CEST 2009@@ -142,19 +142,12 @@ // this will lazy load and update the property logLazy.setDescription("updated log"); - // which should result in two PCE events- assertEquals(2, pces.size());+ // which should result in one PCE events+ assertEquals(1, pces.size()); - // the first for updating the property from null to the value in the database- PropertyChangeEvent lazyLoadEvent = pces.get(0);+ // test for the acutal update of the value+ PropertyChangeEvent propertyChangeEvent = pces.get(0); - assertEquals("description", lazyLoadEvent.getPropertyName());- assertNull(lazyLoadEvent.getOldValue());- assertEquals("log", lazyLoadEvent.getNewValue());-- // the second for the acutal update of the value- PropertyChangeEvent propertyChangeEvent = pces.get(1);- assertEquals("description", propertyChangeEvent.getPropertyName()); assertEquals("log", propertyChangeEvent.getOldValue()); assertEquals("updated log", propertyChangeEvent.getNewValue());