# QueryStream: Build JPA Criteria queries using a Stream-like API

**URL:** <https://discourse.hibernate.org/t/querystream-build-jpa-criteria-queries-using-a-stream-like-api/4693>\
**Category:** Hibernate ORM\
**Created:** [October 23, 2020, 11:13pm UTC](https://discourse.hibernate.org/t/querystream-build-jpa-criteria-queries-using-a-stream-like-api/4693 "2020-10-23T23:13:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Archie\_Cobbs](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/archie_cobbs/32/1253_2.png) [@Archie\_Cobbs](https://discourse.hibernate.org/u/Archie_Cobbs)\
**Post date:** [October 23, 2020, 11:13pm UTC](https://discourse.hibernate.org/t/querystream-build-jpa-criteria-queries-using-a-stream-like-api/4693/1 "2020-10-23T23:13:30Z")

</div>

I do a lot of JPA/Criteria programming and over time have gotten tired of the verbose syntax required when building JPA queries.

After some thought I decided to create an alternative which is modeled after the Java 8 Stream API.

I’ve been using it for a couple of years now, and it is working nicely and is now my preferred way to build queries.

It’s available on github and in Maven central if anyone is interested in trying it out:

> **[querystream/querystream](https://github.com/querystream/querystream)**
>
> Build JPA Criteria queries using a Stream-like API - querystream/querystream

Let me know what you think.

-Archie

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [November 4, 2020, 5:48pm UTC](https://discourse.hibernate.org/t/querystream-build-jpa-criteria-queries-using-a-stream-like-api/4693/2 "2020-11-04T17:48:02Z")

</div>

Cool stuff. Maybe you also like this library called [JINQ](http://www.jinq.org/) which tries to achieve something similar. I personally create a library called [Blaze-Persistence](https://github.com/Blazebit/blaze-persistence#core-quick-start) that allows writing queries in a fluent fashion as well, although not compile time type safe yet. It provides some of the more advanced SQL features though on top of the JPA model like CTEs, recursive CTEs, subqueries in the FROM clause, set operation(UNION, INTERSECT, EXCEPT) support and much more.

---

<div class="post-metadata">

**Author:** ![Archie\_Cobbs](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/archie_cobbs/32/1253_2.png) [@Archie\_Cobbs](https://discourse.hibernate.org/u/Archie_Cobbs)\
**Post date:** [November 4, 2020, 7:25pm UTC](https://discourse.hibernate.org/t/querystream-build-jpa-criteria-queries-using-a-stream-like-api/4693/3 "2020-11-04T19:25:37Z")

</div>

Thanks for the links, interesting stuff.
