After migrating from Spring Boot 2.7 to Spring Boot 3, this warning appears in the logs when executing a query with lock:
"HHH000444: Encountered request for locking however dialect reports that database prefers locking be done in a separate select (follow-on locking); results will be locked after initial query executes"
I checked the Hibernate version, which also changed during the migration
before migration: org.hibernate:hibernate-core:5.6.15.Final
.
after migration: org.hibernate.orm:hibernate-core:6.2.13.Final
.
Here are sample queries I have, there are several and they all look quite similar to these:
@Transactional(propagation = Propagation.MANDATORY)
@Lock(LockModType.PESSIMISTIC_WRITE)
@Query("SELECT n FROM #{#name} n WHERE n.id = ?1")
T findById(UUID id);
@Transactional(propagation = Propagation.MANDATORY)
@Lock(LockModeType.PESSIMISTIC_READ)
boolean IsExists(K id);
I also tried to force this warning to be disabled with query hints by adding such an annotation to methods:
@QueryHints(value = { @QueryHint(name = "hibernate.query.followOnLocking", value = "false") }, forCounting = false)
But that didn’t help either, and the warning still appears. (I am using a PostgreSQL database)
I read an article about this error: HHH000444 warning, follow on locking
And they write that in version 6.2.3.Final there was a bug that caused follow-on locking and it has been fixed, however this kind of warning appears and I don’t know what the bug really means and why it appeared.
Thank you in advance for help.