I have two classes say Foo and Bar mapped as @OneToOne (bidirectional) using Hibernate (3.6.1 final) with JPA (2.0) like -
@Entity public class Foo{ @Id
The correct way to force version update is the following:
em.lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
It's intended to be used in such cases.
Other methods of EntityManager that take LockModeType can be used as well.
EntityManager
LockModeType