CDI Query Module First Alpha Released!

It’s been some months now since we started exploring CDI extensions as a small exercise. As it turned out, the exercise forged into something usable which we’re pushing now in the open as a first Alpha shot.

So I’m happy to announce the availability of the CDI Query Module on Maven Central! The module helps you creating JPA queries with much less boilerplate, and is of course leveraging the CDI extension API as well as Seam Solder. Some of the feature highlights are:

Query By Name

Assuming you have a Person entity which looks probably similar to this:

You can simply create a DAO interface to query for Persons:

This interface does not need to be implemented. A client can just inject it, call the interface method and in the background, the JPA query is automatically created and executed. To create the query, the method name is analyzed and matching the name to entity properties.

Note that the base interface contains also a couple of other methods which you might also expect from an entity DAO. Ideally, you should not need to inject an EntityManager anymore.

Query by Query Strings and Named Queries

Of course matching property names is not extremely safe to refactorings (some more validation support here is on the roadmap) – if you like to have more control over your JPA queries, you can also annotate the method with the query to execute:

Criteria API Simplifications

If you’re not a big fan of query strings but rather prefer using the JPA 2 criteria API, we also allow to simplify this with a small utility API:

All the code is hosted and documented on GitHub. Please:

  • Give feedback! If you find this useful or actually not so, we’re happy to hear what is still missing.
  • Participate! Forking and creating pull requests are really a breeze on GitHub 🙂


  • Bartek Majsak for improving the initial code, taking care about quality reports and soon finalizing the stuff on the validation branch 😉 (just kidding, check out Bartek’s cool work on the Arquillian Persistence Module!)
  • Grails GORM for inspiring me for this Java implementation
  • The CDI folks for a really great specification
  • Last but not least the Arquillian guys, developing and testing this stuff is pure fun with Arquillian!

Never miss an update by following us and subscribing to our monthly newsletter!


Tom Hug

Senior Technology Specialist at Atos Consulting
Tech nerd, OSS contributor and JVM aficionado. Coder at day, gamer at night. The rest of my time belongs to my family.

I have more than 15 years experience building distributed systems, and also know how to deploy and run them. Fluent in Java, and currently polishing again my language skills in Kotlin, C#, JavaScript and Python (in that order of preference).
Article Name
CDI Query Module First Alpha Released!
CDI started extensions as a small exercise. Now the exercise forged into something usable which we're pushing now in the open as a first Alpha shot.
Publisher Name
Atos Consulting CH
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *