On Wednesday, September 24, 2003, at 12:34 PM, Mike Kienenberger wrote:
> Why should CayenneDataObject not be patched to remove these lines?
>
> if (persistenceState == PersistenceState.COMMITTED) {
> persistenceState = PersistenceState.MODIFIED;
> }
Because Cayenne was patched some time back to add these lines :-)
> The official behavior is breaking on my read-only data objects that
> have
> mutable one-to-many relationships to other data objects.
Well, adding an object to a to-many relationship modifies the source
object of such relationship. There are a few reasons to treat such
objects as modified even though no SQL will be generated for them on
commit (there was some discussion on this list some time back).
Technical reason - flattened relationships will stop working. Purely
logical - changing one of the object properties modifies the object,
hence - the state change.
Having said that I guess we should be smarter about read-only entities.
For one thing (unrelated to the present discussion) class generation
shouldn't produce any setters, only getters. This will explicitly show
the user that the object is not for modification.
As for 1..n relationships when to-one is read-only....Maybe instead of
fast failure in commit, first check for db-level modifications, and
ignore purely object-level changes, like to-many array modification....
So the object will still be MODIFIED until commit is executed. After
that it will become COMMITTED even if nothing was saved for this object.
Andrus
This archive was generated by hypermail 2.0.0 : Wed Sep 24 2003 - 20:29:35 EDT