[hibernate-dev] PESSIMISTIC_FORCE_INCREMENT lock mode

Steve Ebersole steve at hibernate.org
Thu Jul 27 14:10:21 EDT 2017


Without looking at the complete passage in Vald's article, I will say that
the single phrase you pulled out of that context is not accurate IMO

On Thu, Jul 27, 2017, 12:01 PM Arnold Gálovics <galovicsarnold at gmail.com>
wrote:

> Hi all,
>
> I'm a bit confused with the mentioned lock mode.
>
> *The doc says the following:*
> *"The entity is locked pessimistically and its version is incremented
> automatically even if the entity has not changed."*
>
> I'm checking this with an H2 DB and the current behavior is the following:
> - the version attribute is incremented in advance, right after fetching
> (I'm using EntityManager#find here, but with lock, it should be the same)
> - the original fetching query contains the SELECT ... FOR UPDATE clause
>
> Knowing this, it seems for me that this lock mode involves a DB lock,
> however the doc doesn't say anything about this, especially whether it's a
> shared or exclusive lock.
>
> I've checked Vlad's article about this.
>
> https://vladmihalcea.com/2015/02/16/hibernate-locking-patterns-how-does-pessimistic_force_increment-lock-mode-work/
>
> It says the following: "*The PESSIMISTIC_FORCE_INCREMENT naming might lead
> you into thinking that you are using a pessimistic locking strategy, while
> in reality this Lock Mode is just an optimistic locking variation."*
>
> So now I'm unsure what this really is.
>
> Could you please briefly describe it to me if I missed something?
>
> Thanks in advance!
>
> Best Regards,
> Arnold
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list