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
abstract fun <T : Any> find(entityClass: Class<T>, primaryKey: Any): T?

Finds a single entity in the persistence context of the specified entity type T and with the specified primaryKey.

@Suspendable
abstract fun <T : Any> find(entityClass: Class<T>, primaryKeys: List<Any>): List<T>

Finds multiple entities of the same type with different primary keys in a single transaction.

Link copied to clipboard
@Suspendable
abstract fun <T : Any> findAll(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
abstract fun <T : Any> merge(entity: T): T?

Merges a single entity in the persistence context in a transaction.

@Suspendable
abstract fun <T : Any> merge(entities: List<T>): List<T>

Merges multiple entities in the persistence context in a single transaction.

Link copied to clipboard
@Suspendable
abstract fun persist(entity: Any)

Persists a single entity to the store.

@Suspendable
abstract fun persist(entities: List<Any>)

Persists multiple entities in the persistence context in a single transaction.

Link copied to clipboard
@Suspendable
abstract fun <T : Any> query(queryName: String, 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. Casts result set to the specified type T.

Link copied to clipboard
@Suspendable
abstract fun remove(entity: Any)

Removes a single entity from the persistence context in a transaction.

@Suspendable
abstract fun remove(entities: List<Any>)

Removes multiple entities from the persistence context in a single transaction.

Extensions

Link copied to clipboard
inline fun <T : Any> PersistenceService.find(primaryKey: Any): T?

Finds a single entity in the persistence context of the specified entity type T and with the specified primaryKey.

inline fun <T : Any> PersistenceService.find(primaryKeys: List<Any>): List<T>

Finds multiple entities of the same type with different primary keys from the persistence context in a single transaction.

Link copied to clipboard

Finds all entities of the same type in a single transaction.