ENTITY
- the entity typepublic abstract class AbstractViewManager<ENTITY> extends Object implements Manager<ENTITY>
AbstractManager
Modifier | Constructor and Description |
---|---|
protected |
AbstractViewManager() |
Modifier and Type | Method and Description |
---|---|
Persister<ENTITY> |
persister()
Returns a
Persister that when its
Persister.apply(java.lang.Object) method is called, will produce
the same result as Manager.persist(java.lang.Object) |
Remover<ENTITY> |
remover()
Returns a
Remover that when its Persister.apply(Object)
method is called, will produce the same result as Manager.remove(Object) |
Stream<ENTITY> |
stream()
Creates and returns a new
Stream over all entities in the
underlying database. |
Updater<ENTITY> |
updater()
Returns an
Updater that when its Persister.apply(Object)
method is called, will produce the same result as Manager.update(Object) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fields, findBackwardsBy, findBy, findByNullable, finderBackwardsBy, finderBy, finderByNullable, getEntityClass, getTableIdentifier, persist, primaryKeyFields, remove, update
public Stream<ENTITY> stream()
Manager
Stream
over all entities in the
underlying database. This is the main query API for Speedment.
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 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 Stream
,
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
Operation.
Some of the Terminal Operations are:
forEach(Consumer)
forEachOrdered(Consumer)
toArray()
toArray(IntFunction)
reduce(BinaryOperation
reduce(Object, BinaryOperator)
reduce(Object, BiFunction, BinaryOperator)
collect(Collector)
collect(Supplier, BiConsumer, BiConsumer)
min(Comparator)
min(Comparator)
count()
anyMatch(Predicate)
noneMatch(Predicate)
findFirst()
findAny()
iterator()
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
peek(Consumer)
will
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'
stream.count();
-> 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
stream
in interface Manager<ENTITY>
java.util.stream
,
Stream
public Persister<ENTITY> persister()
Manager
Persister
that when its
Persister.apply(java.lang.Object)
method is called, will produce
the same result as Manager.persist(java.lang.Object)
public Updater<ENTITY> updater()
Manager
Updater
that when its Persister.apply(Object)
method is called, will produce the same result as Manager.update(Object)
public Remover<ENTITY> remover()
Manager
Remover
that when its Persister.apply(Object)
method is called, will produce the same result as Manager.remove(Object)
Copyright © 2017 Speedment, Inc.. All rights reserved.