I'm now in charged of the following code and I 'm not sure if I correctly understand what the guy was doing .. void methodA(){ sess=SessionFactory.openSession(); tx=sess.beginTransaction(),;
myobj1 = sess.get(MyObj1.class , anInt), myobj2 = myobj1.cloneDeep(); sess.save(myobj2) ; myobj1.setAttrib1(newvalue); myobj1.setAttrib2(newvalue);
tx.commit(); sess.close(); }
myobj1 and 2 are local vars not instVar. What happens here ??
I understand that myobj2 will be newly saved and thus gets a new id in the table (a new row in the table) but what happens with myobj1 does the commit flush the in-memory cache and also save myobj1 thus actually executing an update on the DB of myobj1 ?? Or will the newly assigned values to myobj1 be discarded when method end since myobj1 is locally declared ??
thanks for your help nitro
|