EasyCriteria 3.0 – New Features

Hello, how are you?

It is with a great joy that I announce a new version of the EasyCriteria framework. This new version will make easier and increase the framework utilization (click here if you do not know nothing about the EasyCriteria framework).

2 new features and a huge refactoring are present in this new version, these features/refactoring deserve a new major version in the framework. The new version is now 3.0.

Let us see what is new:

Extreme Refactoring

This refactoring was done to reduce the code complexity, to apply more code patterns, using “final” attribute to make a better memory use and changing “pom.xml” dependences.

Version 3.0

Version 2.2

Notice in the pictures above that the Cyclomatic complexity has been reduced a lot (click here to know more about Cyclomatic complexity). Just the “utils” package that had a small increase of complexity but it had some lines removed.

Multiple Joins! o/

It might look that multiple joins are something easy, but until this version, it was the major feature to be released. Now it is possible to do all the joins that you want, take a look at the code below:

EasyCriteria<Person> easyCriteria = EasyCriteriaFactory.createQueryCriteria(getEntityManager(), Person.class); 
easyCriteria.andEquals("dogs.toys.manufacturer.name", "ACME");

Looking at the code above it is possible to see that it is possible to do “joins” for every method in the framework. Notice that the “andEquals” method is crossing all possible relationships in the entity Person.

The orderBy method also supports multiple joins.

This change will make the EasyCriteria API simpler, now it will not be necessary to call any method with Join in the name to create a “where”. The andJoinEquals method (or any other method with the word “Join” that creates a condition, e.g.: andJoinGreaterThan, andJoinStringIn), is deprecated and will be removed in future versions.


This method allows doing a count in the query result. Take a look at the code below:

EasyCriteria<Person> easyCriteria = EasyCriteriaFactory.createQueryCriteria(getEntityManager(), Person.class);

The code above would count all Person found in the database. But, what about the complicated queries… would it do the count?

The query below would work without problems:

List<String> names = new ArrayList<String>();

EasyCriteria<Manufacturer> easyCriteria = EasyCriteriaFactory.createQueryCriteria(getEntityManager(), Manufacturer.class);
easyCriteria.andStringNotIn("products.sellers.name", names);


List<Manufacturer> manufactures = easyCriteria.getResultList();

Notice in the code above that it is possible to do a count and with the same object execute the query.

One important thing to notice is that the count method ignores the values defined in the methods setFirstResult and setMaxResults. To do a count with firstResult and maxResults it would be necessary to do a SubQuery, and this is not supported yet.

100% of Coverage

This project still with 100% of coverage in the unit tests with OpenJPA, EclipseLink and Hibernate, JUnit and the Cobertura framework.

I hope that this tool will be really useful to you.

To use it with maven, just add to the pom:


To manually download it, click here: http://uaihebert.com/wp-content/uploads/EasyCriteria/EasyCriteria-3.0.0_2013-08-02.jar

See you later.

4 thoughts on “EasyCriteria 3.0 – New Features

    • Danilo, boa tarde.

      Esse suporte ainda não é possível, mas podemos adicionar no roadmap sem problemas.

      Se você quiser, me passe um pseudo código do que você espera exatamente e aí podemos adaptar ao projeto. ;)

      Valeu! [

    • Alexandre, boa tarde.

      Sim. Já está no repositório do maven.
      Sim, pode usar como quiser.
      Sim, 100% de cobertura. [=

      Obrigado pela visita.

Leave a Comment