cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Zeigler <robert.zeig...@roxanemy.com>
Subject Re: False Modified
Date Fri, 11 Mar 2011 20:51:29 GMT
Seems reasonable to me. Especially since commitChanges is a no-op in that situation. 
Also, that's how property change listeners in java beans work... only fire if the old and
new values are different (see http://download.oracle.com/javase/7/docs/api/java/beans/PropertyChangeSupport.html#firePropertyChange(java.beans.PropertyChangeEvent).
 Not that these are property change listeners... but it meets prior expectation.

Robert

On Mar 11, 2011, at 3/112:22 PM , Michael Gentry wrote:

> I just did a quick test using:
> 
>        DataContext dataContext = DataContext.createDataContext();
> 
>        User user = dataContext.newObject(User.class);
> 
>        user.setFirstName("System");
>        user.setLastName("Administrator");
>        user.setUsername("admin");
> 
>        dataContext.commitChanges();
> 
>        user.setFirstName("System"); // This isn't a real change
> 
>        System.out.println(dataContext.hasChanges());
> 
>        dataContext.commitChanges();
> 
> In a nutshell, create a user, commit it, set a value to the same
> value, then check hasChanges().  The output is:
> 
> 
> INFO: INSERT INTO Users (first_name, id, last_name, password,
> username) VALUES (?, ?, ?, ?, ?)
> INFO: [bind: 1->first_name:'System', 2->id:200,
> 3->last_name:'Administrator', 4->password:NULL, 5->username:'admin']
> true
> 
> The "true" is that the dataContext has changes, even though the second
> commitChanges() doesn't do anything (there are no real changes).
> Should we modify CayenneDataObject's writeProperty() to check if the
> old value and new value are equal before calling propertyChanged()?  I
> was also noticing Embeddables doing something similar.
> 
> Thanks,
> 
> mrg


Mime
View raw message