Suppose I have the following situation:
One table is selected and one object is retrieved. i perform changes in this object, and then flush the session. ok, the changes are going to be noticed and updated.
But, if for a special reason, i have to add another object to the same table, before flushing the modifications of the first retrieved object (the first object has nothing to do with the second.they are members of the same table. no integrity relations between them). Do I have to flush the session to save the modifications in the first object before saving the second one? is it possible to flush the session twice?
Example:
Code:
Object one = (Object)session.load(Object.class, id);
one.setThis(...);
one.setThat(...);
Object two = new Object();
two.setThis(...);
two.setThat(...);
session.save(two); // save the new instance
session.flush();// flushes all, and updates the object one modifications.
This is setting things whith wrong ids in the tables. so , i get a new Object instance with id 0 in the database table.But forget the results. just tell me if this is ok. if not, any help? ;)))
Thanks a lot.