Unintended save cascade

Hello,



I have defined an object hierarchy without any cascading, but nevertheless all modified objects are updated in the database.

Is this intended, or is it a bug, or am I simply misunderstanding something here?



The cascade applies for Save/Update operations. But note that Update operation means putting a dettached object into the manager. What actually performs the update is the Flush operation, which commits all changes in all objects in the manager. Maybe that's what you are referring to?

Yes, you're right.



So is there a way to commit only some changes?

I already learned that there is no way to rollback changes, and also no way to refresh certain objects (at least not yet), but there must certainly a way to explicitly store only what I want?



Unfortunately no. I'm curious, in which case you would want to do that?

Well, I guess this must be a very common use case.

I have plenty of objects which can be created/edited/deleted in various parts of a GUI. The different sections each have a 'save' button, but unfortunately this saves all modified objects, not just those for which the 'save' button has been pressed (which calls a SaveOrUpdate, followed by a Flush).

In this case, why don't you separate the different save operations in different object managers? Considering each object manager as a unit of work?

I see.

Will this also work if there are relations between objects, as described in first post?

All the related objects should be in the same manager, but you can use transient objects and "put" objects in manager as you want just for save/update operations.