Hi Catalinus,
I guess the answer is yes and no. SaveOrUpdate is only useful if you work with an decoupled instance of your entity. Meaning, if you have an object in memory, which is not connected to a hibernate session, hibernate does not yet know what to do with it when you "add" it to the session. SaveOrUpdate will be the most resource consuming (I would assume), as it will try to figure out by itself if this entity already exists in the database or not, while a pure save will assume that it is a new instance.
So, the answer here is no. You have to do a Save, Update or SaveOrUpdate on an object, that is not connected to a session.
If your object is loaded from a session and is still connected to it and you have configured your hbm file that way, it will cascade the changes upon a Commit (in case of a transaction) or Flush on the session. I'm not quite certain if this is the default behaviour or not, since we did some changes in code to emulate the 1.x default behaviour in our application when we migrated to 2.x.
I hope that my answer will help you a little.
Kind regards, Marco...
|