PersistenceService

@DoNotImplement
interface PersistenceService

PersistenceService allows a flow to insert, find, update and delete custom entities in the persistent store provided by the platform.

Corda provides an instance of PersistenceService to flows via property injection.

Functions

Link copied to clipboard
@Suspendable
@Nullable
abstract fun <T> find(@NotNull entityClass: Class<T>, @NotNull primaryKey: Any): T
Finds a single entity in the persistence context of the specified entity type [T] and with the specified primaryKey.
@Suspendable
@NotNull
abstract fun <T> find(@NotNull entityClass: Class<T>, @NotNull primaryKeys: List<out Any>): List<T>
Finds multiple entities of the same type with different primary keys in a single transaction.
Link copied to clipboard
@Suspendable
@NotNull
abstract fun <T> findAll(@NotNull entityClass: Class<T>): PagedQuery<T>
Creates a PagedQuery to find all entities of the same type from the persistence context in a single transaction.
Link copied to clipboard
@Suspendable
@Nullable
abstract fun <T> merge(@NotNull entity: T): T
Merges a single entity in the persistence context in a transaction.
@Suspendable
@NotNull
abstract fun <T> merge(@NotNull entities: List<T>): List<T>
Merges multiple entities in the persistence context in a single transaction.
Link copied to clipboard
@Suspendable
abstract fun persist(@NotNull entity: Any)
Persists a single entity to the store.
@Suspendable
abstract fun persist(@NotNull entities: List<out Any>)
Persists multiple entities in the persistence context in a single transaction.
Link copied to clipboard
@Suspendable
@NotNull
abstract fun <T> query(@NotNull queryName: String, @NotNull entityClass: Class<T>): ParameterizedQuery<T>
Creates a ParameterizedQuery to support a named query to return a list of entities of the given type in a single transaction.
Link copied to clipboard
@Suspendable
abstract fun remove(@NotNull entity: Any)
Removes a single entity from the persistence context in a transaction.
@Suspendable
abstract fun remove(@NotNull entities: List<out Any>)
Removes multiple entities from the persistence context in a single transaction.