Search
Calendar
April 2024
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
282930  
Your widget title
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