Recent Posts
Archives

Posts Tagged ‘select for update’

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:

[java]sessionFactory.getCurrentSession().load(MyMappedClass.class, myPk, LockMode.UPGRADE);[/java]