ENTITY- the entity type
|Modifier||Constructor and Description|
|Modifier and Type||Method and Description|
Creates and returns a new
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findBackwardsBy, findBy, findByNullable, finderBackwardsBy, finderBy, finderByNullable, persist, remove, update
Streamover all entities in the underlying data source (e.g database). This is the main query API for Speedment.
The order in which elements are returned when the stream is eventually consumed is unspecified. The order may even change from one invocation to another. Thus, it is an error to assume any particular element order even though is might appear, for some stream sources, that there is a de-facto order.
Mutable elements are not reused within the stream. More formally, there
are no pair of mutable stream elements
e2 such that
e1 == e2.
The Stream will never contain
This is an inexpensive O(1) operation that will complete in constant time regardless of the number of entities in the underlying database.
The returned stream is aware of its own pipeline and will optionally optimize its own pipeline whenever it encounters a Terminal Operation so that it will only iterate over a minimum set of matching entities.
When a Terminal Operation is eventually called on the
that execution time of the Terminal Operation will depend on the
optimized pipeline and the entities in the underlying database.
The Stream will be automatically
closed after the Terminal
Operation is completed or if an Exception is thrown during the Terminal
Some of the Terminal Operations are:
reduce(Object, BiFunction, BinaryOperator)
collect(Supplier, BiConsumer, BiConsumer)
Any Terminating Operation may throw a
SpeedmentException if the
underlying database throws an Exception (e.g. an SqlException)
Because the Stream may short-circuit operations in the Stream pipeline,
methods having side-effects (like
potentially be affected by the optimization.
Here are some examples of how the stream optimization might work:
stream .filter(Hare.NAME.equal("Henry") .collect(toList());
-> select * from hares where name='Henry'
-> select count(*) from hares
stream .filter(Hare.NAME.equal("Henry") .count();
-> select count(*) from hares where name='Henry'
stream .filter(Hare.NAME.equal("Henry") .filter(Hare.AGE.greaterThan(5) .count();
-> select count(*) from hares where name ='Henry' and age > 5
Persisterwhich can be used to persist entities in the underlying database.
public Persister<ENTITY> persister(HasLabelSet<ENTITY> fields)
Persisterthat operates on a given subset of entity fields. Useful for example when persisting an entity with auto incremented fields of fields with defaults. See
Updaterwhich can be used to update entities in the underlying database.
public Updater<ENTITY> updater(HasLabelSet<ENTITY> fields)
Updaterthat operates on a given subset of entity fields. Useful for example when persisting an entity with auto incremented fields of fields with defaults. See
Copyright © 2019 Speedment, Inc.. All rights reserved.