Hi,

at rcp frontend we use the following generated method to save new objects.

---

     public void save(RichPerson richPerson) {
         boolean isNew = (richPerson.isNew());
         Person updatedPerson = richPerson.toModel(true);

         Person savedPerson =
             personService.save(createServiceContext(), updatedPerson);
         if (!updatedPerson.equals(savedPerson)) {
             Object savedKey = savedPerson == null ? null : 
savedPerson.getKey();
             throw new IllegalStateException(
                 "Expected retrieved to be equal to saved, " +
                 updatedPerson.getKey() + " != " + savedKey + " : " +
                 savedPerson);
         }
         richPerson.fromModel(savedPerson);

         DataEvent event =
             new DataEvent(richPerson,
                 (isNew ? DataEvent.Action.INSERT : 
DataEvent.Action.UPDATE));
         notifyView(event);

     }


---

But on new RichPersons we got the IllegalStateException. This comes 
because the uuid of savedPerson and for updatedPerson is called first in 
updatedPerson.equals(savedPerson) for each object, and therefore its 
different.

Should we add the getKey() in the RichPerson.toModel(true) method? Or 
should we add the uuid-generator in the c'tor of the PesonBase? Or is 
something other wrong here?

In the save method, I could also check if (isNew && 
!updatedPerson.equals(savedPerson)) but this is an workaround and not an 
solution.


Regards
    Steffen...

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to