I'm working with the hibernate template using Oracle 9i. I have a dao object with code that looks like this:
For some reason, every time the object gets loaded, the version number used for optimistic locking (set using the "version" setting in the hibernate mapping) is ALWAYS incremented. This shouldn't be happening and I can't figure out why it would be happening. The unit test I run with this checks this code only, so there's nothing else happening. If you replace the two most important lines with the following, the version number doesn't get incremented, which is what should be happening:Code:MyObject result = null; try { HibernateTemplate template = new HibernateTemplate(getSessionFactory()); result = (MyObject) template.load(MyObject.class, id, LockMode.READ); } catch (Throwable t) { processThrowable(t); } return result;
So using the standard loading does not increment the version number. I am certain that I don't want version numbers incremented on every load. What could be causing this? Is it somehow related to the behind-the-scenes work spring does with the hibernate template to bind to the current thread?Code:session = getSessionFactory().openSession(); result = (MyObject) session.load(MyObject.class, id, LockMode.READ);


Reply With Quote