1
2
3
jpaStreamer.stream(User.class)
1
2
3
4
5
6
jpaStreamer.stream(User.class)
.filter(User$.age.equal("22"))
.sorted(User$.name.reversed())
.skip(10)
.limit(5)
.forEach(System.out::println);
"JPAStreamer is really beautiful, and I will start using it to make my code more readable."
"Your framework seems to me to be one of the best and most beautiful code style projects I’ve ever seen for Java."
- Robert Zeranski
Head of Software Development, Dako
"Wicked cool!"
- StackOverflow user
JPAstreamer is a library for expressing JPA/Hibernate/Spring queries using standard Java streams. JPAstreamer instantly gives Java developers type-safe, expressive and intuitive means of obtaining data in database applications.
JPAstreamer provides a fully type-safe query API. This helps to instantly detect errors and allows you to utilize code-completion for increased efficiency when coding.
Java Stream is a declarative interface that is designed for expressing what you want, rather than how to obtain that result. As a result, your queries can be more terse while remaining expressive and intuitive to read.
With JPAstreamer, queries are expressed in pure Java. Hence you can avoid any impedances mismatches between JPQL/HQL and Java.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@Entity
@Table(name = "user", schema = "mysql")
public class User implements Serializable {
@Id
@Column(name = "user_id", nullable = false)
private Integer userId;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "age")
private Integer age;
}
JPAstreamer relies on existing JPA entities to generate static metamodel classes needed for typesafe Stream parameters. Upon compilation, an annotation processor generates predicate field builders for all classes annotated with @Entity.
1
2
@Autowired
private final JPAStreamer jpaStreamer;
1
var jpaStreamer = JPAStreamer.of("mysql");
JPAstreamer is generally initiated with a builder. Although, Spring users have the option to use dependency injection with the @Autowired annotation.
1
2
3
4
5
6
jpaStreamer.stream(User.class)
.filter(User$.age.equal("22"))
.sorted(User$.name.reversed())
.skip(10)
.limit(5)
.forEach(System.out::println);
Stream any @Entity and apply a custom pipeline to fetch relevant data. Predicates are expressed using the generated field builder, in this case User$. The actual data fetching is delegated to the JPA provider.
Just add a single dependency to your build and start streaming. No configuration needed.
Integrates seamlessly with any existing JPA provider e.g. Hibernate, Spring Data, and TopLink.
Compatible with the Java Platform Module System (JPMS) for lightweight installation.
The Java Stream API is an integral part of the Java language since Java 8 that has received praise for offering a declarative and expressive code style.
Enriches the API of JPA providers to include standard Java Stream as a way of expressing queries without impact on the existing application.
A custom implementation of the Stream API allows shortcutting of operations to form optimal JPA queries.
Writing Hibernate queries using the Criteria API can be anything but intuitive and comes at the expense of wordiness. In this article, you will learn how the JPAStreamer Quarkus extension facilitates intuitive and type-safe Hibernate queries...
Writing Hibernate queries using the Criteria API can be anything but intuitive and comes at the expense of wordiness. In this article, you will learn how the JPAStreamer Quarkus extension facilitates intuitive and type-safe Hibernate queries...
For the past 10 or so years, JPA has been one of the most popular ways of accessing a database within the Java ecosystem. Even if you haven’t heard of JPA directly, there is a high likelihood that you’ve heard of Hibernate...
For the past 10 or so years, JPA has been one of the most popular ways of accessing a database within the Java ecosystem. Even if you haven’t heard of JPA directly, there is a high likelihood that you’ve heard of Hibernate...
JPAstreamer is an open source Java library powered by Speedment technologies. Speedment is based in Palo Alto and is specialized on Java Streams and low-latency data processing.
Copyright © 2023 Speedment, Inc. All rights reserved.