I need this roadmap of a Hibernate managed object instance.
First, I create an instance with initial properties and persist this object in a db. Then session associated with this object is closed. But still, I serialize my object and on the next step deserialize it, invoke some setters, and again, I need to update what changed in a database.
What methods of Hibernate session should I use? persist() or save() on the first step and saveOrUpdate() on the second?
In fact I see that saveOrUpdate() can be used on each step. The only problem is that as I see, it does not return an associated PK. Do you know how to get it when we persist the object for the first time? I suppose, after we persist the object, it gets an id field set, so after invokation of saveOrUpdate(myObject), myObject.getId() returns the PK?
What would you recommend?