Search
Calendar
June 2025
S M T W T F S
« May    
1234567
891011121314
15161718192021
22232425262728
2930  
Archives

PostHeaderIcon “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);

Leave a Reply