Hi,
I'm trying to understand the purpose of setReadOnly() method of hibernate's session class.
I have the following (pseudo)
Code:
Cat cat=session.get(Cat.class,1L);
session.setReadonly(cat, true);
cat.setName("changed");
....
...
...
session.setReadonly(cat, false);
session.saveOrUpdate(cat);
Apparently, with this code, the name of the cat is not going to get updated to 'changed', even
though I've flagged the setReadonly as 'false'.
Also... even if I remove the call to session.setReadonly(cat, true), the cat is never going to get updated.
I've done a bit of reading... and apparently by setting setReadOnly(..,false), the 'loaded' state is going to
get synced with the current state, hence Hibernate's dirty checking always return false (which means
object changes is not going to get persisted?).... if so.... what is the purpose of giving the boolean parameter
to setReadOnly method?
Am I missing something here? Maybe the method name is misleading? Apology if the pseudo code
above is not clear... but I hope you get the idea..
Regards,
Alex.