EasyCriteria 1.0 Released
EasyCriteria is an open source tool to make the JPA Criteria code for any kind of JPA implementation easier . EasyCriteria has 100% of coverage on its tests with JUnit and it is tested with Hibernate, OpenJPA and EclipseLink.
If you want to understand the Criteria ideal and how to apply it to your code check this post: EasyCriteria – An easy way to use the JPA Criteria
The new EasyCriteria functionality includes:
- Join with conditions
- Query Pagination
Now it is possible to do a Join and add parameters to it:
EntityManager em = emf.createEntityManager(); EasyCriteria<Person> easyCriteria = EasyCriteriaFactory.createQueryCriteria(em, Person.class); easyCriteria.innerJoin("dogs", Dog.class); easyCriteria.whereJoinEquals("dogs", "name", "Dark"); easyCriteria.whereJoinStringNotIn("dogs", "name", names); // names is a List<String> easyCriteria.whereJoinStringLike("dogs", "name", "M%"); easyCriteria.whereJoinListIsEmpty("dogs", "cars"); easyCriteria.whereJoinAttributeIsNull("dogs", "nickName"); easyCriteria.whereJoinStringBetween("dogs", "name", "A", "L");
The query can be paginated:
EasyCriteria<Dog> eascyCriteria = EasyCriteriaFactory.createQueryCriteria(getEntityManager(), Dog.class); eascyCriteria.setFirstResult(0); eascyCriteria.setMaxResults(5);
This new version also has 100% of code coverage.
Click here to download the code of this post with EasyCriteria. With this code you can test EasyCriteria as you like.
In the project page (http://easycriteria.uaihebert.com/) you will find all documentation.
If you have any doubt, just post it.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)