Hello,
I am in the process of migrating from Hibernate 3.6.10 to 4.2.3.
I notice a behavior difference between these two versions if it comes to the usage of the OPTIMISTIC_FORCE_INCREMENT lock on an entity.
Let's say that I have an existing entity with a version=0. If I then do the following:
1. load the entity through the EntityManager (version=0) 2. Apply the OPTIMISTIC_FORCE_INCREMENT lock on the entity 3. Modify the entity through a setter of an attribute 4. Flush the entity manager. This results in a version increment => version=1 5. Commit the transaction. For 3.6.10, the version is not incremented (version=1). For version 4.2.3 the version is incremented (version=2)
Since I am using DTOs to communicate objects back towards the client, this 4.2.3 behavior is a big issue to me. The conversion from entity to dto is done between the flush and commit (step 4 and 5). Using 4.2.3 this will result in having the client seeing an outdated version of the version, which is highly undesirable.
Is there anything I can do to tweak this behavior? If not, would this be a bug? (it definitely is not backwards compatible).
I would expect that if between a flush and commit no modifications occur on an entity, there would be no further database updates when doing the commit, or am I wrong on that?
All help is appreciated! Thanks in advance, Kind regards, Franck de Bruijn
|