Warning Hibernate HHH000444 using Oracle 10g with WildFly 8.0.0 - follow-on locking

1

When doing some queries on a view using JPA (2.1) with Hibernate , I'm having this warning . Although it's working and just being a warning , it bothers me a little.

  

WARN org.hibernate.loader.Loader - HHH000444: Encountered request for   locking   in a separate select (follow-on locking); results will be locked after   initial query execute

This occurs in the following environment:

  • JPA 2.1 / Hibernate 4.3.0.Final;
  • WildFly 8.0.0.Final;
  • Oracle DB 10g;

In addition, by doing research on this warning, I came up with a bug report for the Hibernate staff who turned out to be rejected . In the bug, the problem also seems to occur in Oracle 11g .

How to correct or avoid this warning?

    
asked by anonymous 27.03.2014 / 12:53

2 answers

2

The warning occurs because lock in the same query by default is turned off. And it was disconnected for Oracle given its limitations in being able to do select for update in several situations, mainly with queries involving pagination (which in oracle 10 needs rownum + order by).

If you do not lock in queries with pagination, you can return the behavior in the dialect. If it is used, change your query to first lock in a separate query, or use native query.

The default hibernate behavior in this case represents an error, since the second-select lock represents a competition problem because the registry may have been changed between the two selects and the data used in the first one will be different from expected

    
18.02.2017 / 12:07
-1

I do not know if this can be considered a defect or not. But what happens is that in the dialect implemented by Hibernate for Oracle databases ( org.hibernate.dialect.Oracle10gDialect ), it is returning true in the method that informs the use of useFollowOnLocking . This ends up generating the warning. Do not ask me what followOnLocking does because I do not know yet.

To suppress the problem , we need to create a class that extends the org.hibernate.dialect.Oracle10gDialect class and we should override the public boolean useFollowOnLocking() method to return false .

So, the class looks like this:

import org.hibernate.dialect.Oracle10gDialect;

public class MeuDialetoOracle10g extends Oracle10gDialect {

    @Override
    public boolean useFollowOnLocking() {
        return false;
    }
}

After this, you simply declare this dialect to be used in persistence.xml :

<property name="hibernate.dialect" value="br.com.meu.pacote.MeuDialetoOracle10g"/>

And that's it. The warning leaves.

    
27.03.2014 / 12:53