“Select for update” in Hibernate
Case:
You have to use an equivalent to “select for update
” in Hibernate, for instance when you migrate en EJB entity to Hibernate.
Fix:
In your query, use the option LockMode.UPGRADE
. For instance, you will have:
sessionFactory.getCurrentSession().load(MyMappedClass.class, myPk, LockMode.UPGRADE);