FAQ
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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 9 | next ›
Discussion Overview
groupdev @
categoriescayenne
postedMar 11, '11 at 8:23p
activeMar 12, '11 at 1:42p
posts9
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase