I've added a @Version annotation to my entity beans, hoping to take advantage of the optimistic locking provided by JBoss. My understanding is that the EntityManager is responsible for incrementing the version number when an object is persisted; is this correct?
Currently, the EntityManager is not updating the Version property when an object is persisted. The EntityManager is, however, throwing StaleObject exceptions if I manually change the version number on an Entity and then try to persist it.
Is there extra configuration needed to enable version incrementing when objects are persisted, or is this not possible / supported?
it should work fine.
What you need in your hbm files is:
<class name="com.canpay.gm.persistent.model.BankAccount" table="BankAccount" optimistic-lock="version">
<id name="id" column="id" type="long" unsaved-value="null">