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 which can be used to persist
entities in the underlying database. |
Persister<ENTITY> |
persister(HasLabelSet<ENTITY> fields)
Provides a
Persister that operates on a given subset of entity fields. |
Remover<ENTITY> |
remover()
Returns a
Remover which can be used to remove
entities in the underlying database. |
Stream<ENTITY> |
stream()
Creates and returns a new
Stream over all entities in the
underlying data source (e.g database). |
Updater<ENTITY> |
updater()
Returns a
Updater which can be used to update
entities in the underlying database. |
Updater<ENTITY> |
updater(HasLabelSet<ENTITY> fields)
Provides a
Updater that operates on a given subset of entity fields. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindBackwardsBy, findBy, findByNullable, finderBackwardsBy, finderBy, finderByNullable, persist, remove, updatefields, getEntityClass, getTableIdentifier, primaryKeyFieldspublic Stream<ENTITY> stream()
ManagerStream over 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.
If a deterministic order is required, then make sure to invoke the
Stream.sorted(java.util.Comparator) method on the Stream
returned.
Mutable elements are not reused within the stream. More formally, there
are no pair of mutable stream elements e1 and
e2 such that e1 == e2.
The Stream will never contain null elements.
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 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,
Streampublic Persister<ENTITY> persister()
PersistenceProviderPersister which can be used to persist
entities in the underlying database.persister in interface PersistenceProvider<ENTITY>Persister.apply(ENTITY)public Persister<ENTITY> persister(HasLabelSet<ENTITY> fields)
PersistenceProviderPersister that operates on a given subset of entity fields. Useful
for example when persisting an entity with auto incremented fields of fields with
defaults.
See PersistenceProvider.persister()persister in interface PersistenceProvider<ENTITY>fields - the fields to persist, any others are ignoredpublic Updater<ENTITY> updater()
PersistenceProviderUpdater which can be used to update
entities in the underlying database.updater in interface PersistenceProvider<ENTITY>Updater.apply(ENTITY)public Updater<ENTITY> updater(HasLabelSet<ENTITY> fields)
PersistenceProviderUpdater that operates on a given subset of entity fields. Useful
for example when persisting an entity with auto incremented fields of fields with
defaults.
See PersistenceProvider.updater()updater in interface PersistenceProvider<ENTITY>fields - the fields to updatepersist, any others are ignoredpublic Remover<ENTITY> remover()
PersistenceProviderRemover which can be used to remove
entities in the underlying database.remover in interface PersistenceProvider<ENTITY>Remover.apply(ENTITY)Copyright © 2019 Speedment, Inc.. All rights reserved.