CRUDService

abstract class CRUDService<I : Serializable, E : CRUDEntity<I>, out M : CRUDModel<I>, in CM : CRUDCreateModel, in UM : CRUDUpdateModel, out R : CRUDRepository<I, E>, out Mapper : CRUDMapper<I, E, M, CM, UM>>(val typeName: String, instantProvider: InstantProvider, repository: R, mapper: Mapper)(source)

Base implementation of a CRUD service for business layer

This is meant to be extended from a @Service class.

Parameters

I

Id type of the data

M

Model type of the data which is a CRUDModel

E

Entity type of the data which is a CRUDEntity

CM

Create model type of the data which is a CRUDCreateModel

UM

Update model type of the data which is a CRUDUpdateModel

R

Repository type of the data which is a CRUDRepository

Mapper

Mapper type of the data which is a CRUDMapper

Constructors

Link copied to clipboard
fun <out R : CRUDRepository<I, E>, out Mapper : CRUDMapper<I, E, M, CM, UM>> CRUDService(typeName: String, instantProvider: InstantProvider, repository: R, mapper: Mapper)

Properties

Link copied to clipboard
open val typeName: String

Type name of the data this service manages

Functions

Link copied to clipboard
@Transactional(rollbackFor = [Exception::class], isolation = Isolation.READ_COMMITTED)
open fun create(createModel: CM, parameters: Parameters): M

Default implementation for creating a new entity from given create model

Link copied to clipboard
@Transactional(rollbackFor = [Exception::class], isolation = Isolation.READ_COMMITTED)
open fun delete(id: I, parameters: Parameters)

Default implementation for deleting an entity with given id

Link copied to clipboard
@Transactional(isolation = Isolation.REPEATABLE_READ, readOnly = true)
open fun get(id: I, parameters: Parameters): M?

Default implementation for getting an entity with given id

Link copied to clipboard
@Transactional(isolation = Isolation.REPEATABLE_READ, readOnly = true)
open fun list(pageable: Pageable, parameters: Parameters): Paged<M>

Default implementation for listing entities with given pagination

Link copied to clipboard
@Transactional(rollbackFor = [Exception::class], isolation = Isolation.READ_COMMITTED)
open fun update(id: I, updateModel: UM, parameters: Parameters): M

Default implementation for updating an entity with given id with given update model data

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard