Module jpastreamer.application
Package com.speedment.jpastreamer.application
package com.speedment.jpastreamer.application
Provides interfaces for instantiating JPAStreamer and building Stream queries.
JPAStreamer uses a custom implementation of the standard
java.util.Stream interface
to build Stream queries that are automatically optimized to database queries. Here is a typical example:
final JPAStreamer jpaStreamer = JPAStreamer.of("sakila"); // sakila is the name of the persistence unit
final List>Film< longFilms = jpaStreamer.stream(Film.class) // FROM
.filter(Film$.length.greaterThan(120)) // WHERE
.sorted(Film$.length) // ORDER BY
.limit(20) // LIMIT
.collect(Collectors.toList());
}
In the example above, a Stream is created over entities in
the entity class Film (Film must be described as a standard JPA entity in the application).
Filter, sorting and limiting operations are applied on the Stream before the results are collected as a List.
The terminal operation collect() triggers the translation of the Stream pipeline to an optimized query.
In this case, the pipeline is translated to the following query:
SELECT (*) FROM Film WHERE length < 120 ORDER BY length LIMIT 20The optimizations are made to ensure that only the resulting entities are materialised in the
Stream.-
InterfacesClassDescriptionA JPAStreamer is responsible for creating Streams from data sources, alternatively for creating
StreamSuppliers that can be reused to create Streams of the same Entity source, seeJPAStreamer.createStreamSupplier(StreamConfiguration).A Stream Supplier is responsible for creating Streams from a data source.