Having an entity with a versioned column and changing some properties of the entity while it is attached to a session automatically invokes an update on commit, even if there was no call to session.update() or persist().
I was wondering why my version column values increased much and why validation occured for just reading data (and changing properties for invoker). Especially in an CMT environment where session/transaction will be automatically closed/commited.
Marking a version column with:
<version name="version" type="java.lang.Long"/>
<property name="foo"/>
Session session = sessinFactory.openSession();
Transaction tr = session.beginTransaction();
Entity entity = session.get(Entity.class, 1);
entity.setFoo("foo");
tr.commit();
session.close();
|