My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Tuesday, November 5, 2013

Hibernate – useFollowOnLocking warning


WARN  org.hibernate.loader.Loader - 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

Solution
This appears to happen with Oracle and the fix is to create a custom dialect as follows

import org.hibernate.dialect.Oracle10gDialect;

public class BatchOracleDialect extends Oracle10gDialect{
          @Override
          public boolean useFollowOnLocking() {
             return false;
          }
}

Now change your hibernate.cfg.xml as follows
<property name="hibernate.dialect"><<package>>.BatchOracleDialect</property>