Is there a performance difference between the two instructions?

I have the following criteria specification and want to know if there is a difference in performance or memory usage. 1st way:

criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO))
        .add(Restrictions.eq("case.estadoAdministrativo", Caso.EstadoAdministrativo.TARIFICADO));

The second way:

criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO));
criteria.add(Restrictions.eq("case.estadoAdministrativo",Caso.EstadoAdministrativo.TARIFICADO));
+3
source share
3 answers

In short, no. After compilation, the .add and .add criteria will become functionally identical. There is a chance that one or the other will be a little faster to compile, but the difference will be that a few nanoseconds of compilation time and no differences at run time.

+1
source

, add this ( ), .

+4

Nope. From the api documentation at http://docs.jboss.org/hibernate/core/3.3/api/

add(Criterion criterion)
    Add a restriction to constrain the results to be retrieved.

You have not yet received any results. None of your restrictions will matter until you call .list ()

+1
source

Source: https://habr.com/ru/post/1751424/


All Articles