ENTITY
- the entity type@FunctionalInterface public interface Persister<ENTITY> extends UnaryOperator<ENTITY>, Consumer<ENTITY>
UnaryOperator
- and
Consumer
-interfaces so that it can be used inside a Stream
.Modifier and Type | Method and Description |
---|---|
default void |
accept(ENTITY entity)
Persists the entity in the data store.
|
ENTITY |
apply(ENTITY entity)
Persists the provided entity to the underlying database and returns a
potentially updated entity.
|
identity
ENTITY apply(ENTITY entity) throws SpeedmentException
SpeedmentException
is thrown.
It is unspecified if the returned updated entity is the same provided entity instance or another entity instance. It is erroneous to assume either, so you should use only the returned entity after the method has been called. However, it is guaranteed that the provided entity is untouched if an exception is thrown.
The fields of returned entity instance may differ from the provided entity fields due to auto generated column(s) or because of any other modification that the underlying database imposed on the persisted entity.
apply
in interface Function<ENTITY,ENTITY>
entity
- to persistSpeedmentException
- if the underlying database throws an exception
(e.g. SQLException)default void accept(ENTITY entity)
accept
in interface Consumer<ENTITY>
entity
- the entity to persistSpeedmentException
- if persisting the entity failedCopyright © 2019 Speedment, Inc.. All rights reserved.