title: Hibernate warning about follow-on locking using Oracle 10g
body: <p>I am using Hibernate 4.3.0.Final / JPA 2.1, Hibernate Search 4.5.0.Final running on WildFly 8.0.0.Final. <strong>My application works absolutely fine</strong>, but I am getting this hibernate warning when the indexes are being created.</p>
  
  <blockquote>
    <p>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 execute</p>
  </blockquote>
  
  <p>This is the method that creates the index:</p>
  
  <pre><code>public void createIndex() throws DAOException {
      FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(this.entityManager);
  
      try {
          fullTextEntityManager.createIndexer(Colaborador.class)
              .purgeAllOnStart(Boolean.TRUE)
              .optimizeOnFinish(Boolean.TRUE)
              .startAndWait();
          }
          catch (InterruptedException e) {
              logger.error("Error creating index", e);
              throw new DAOException(e);
      }
  }
  </code></pre>
  
  <p>I've done some searches and I found a "solution" or, better saying, <strong>a way to suppress the warning</strong>. However, I don't know if this is the best solution. The solution proposes to extend the <code>org.hibernate.dialect.Oracle10gDialect</code> and override the method <code>public boolean useFollowOnLocking()</code> to return <code>false</code>.</p>
  
  <p>Other important thing: this only happens after Hibernate version 4.2.0.Final. Before this version, there isn't a <code>useFollowOnLocking()</code> method.</p>
  
  <p>The new dialect:</p>
  
  <pre><code>import org.hibernate.dialect.Oracle10gDialect;
  
  public class MyOracle10gDialect extends Oracle10gDialect {
  
      @Override
      public boolean useFollowOnLocking() {
          return false;
      }
  }
  </code></pre>
  
  <p>I found this solution <strong><a href="https://forum.hibernate.org/viewtopic.php?f=1&amp;t=992697&amp;view=next">here</a></strong> and <strong><a href="http://reach2ramesh.blogspot.com.br/2013/11/hibernate-usefollowonlocking-warning.html">here</a></strong>. There is also a <strong><a href="https://hibernate.atlassian.net/browse/HHH-8135">bug report</a></strong> that was reject about this warning. I've not found any other solution available for this warning.</p>