cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject False Modified
Date Fri, 11 Mar 2011 20:22:37 GMT
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