Package dev.akif.crud
Interface CRUDRepository<I extends Serializable,E extends CRUDEntity<I,E>>
- Type Parameters:
I
- Id type of the dataE
- Entity type of the data
- All Superinterfaces:
org.springframework.data.repository.Repository<E,
I>
- All Known Subinterfaces:
SimpleRepository<I,
,E> SimplerRepository<I,
,E> SimplestRepository<I,
E>
@NoRepositoryBean
public interface CRUDRepository<I extends Serializable,E extends CRUDEntity<I,E>>
extends org.springframework.data.repository.Repository<E,I>
Base interface of a CRUD repository for data layer
This is meant to be implemented from a @Repository
interface.
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.data.domain.Page<E>
findAllByDeletedAtIsNull
(org.springframework.data.domain.Pageable pageable) Finds all entities for given pagination and deletion flagFinds an entity with given id and deletion flagvoid
flush()
Flushes changes made to the entities, meaning any change will be persisted.Saves given entity, used when creating a new entityint
updateByVersion
(E entity, int version) Updates given entity if it is at given version
-
Method Details
-
findAllByDeletedAtIsNull
org.springframework.data.domain.Page<E> findAllByDeletedAtIsNull(org.springframework.data.domain.Pageable pageable) Finds all entities for given pagination and deletion flag- Parameters:
pageable
-Pageable
for the pagination- Returns:
Page
of found entities
-
findByIdAndDeletedAtIsNull
Finds an entity with given id and deletion flag- Parameters:
id
- Id of the entity to find- Returns:
- Found entity in an
Optional
-
save
Saves given entity, used when creating a new entity- Parameters:
entity
- Entity to save- Returns:
- Saved entity
-
updateByVersion
Updates given entity if it is at given version- Parameters:
entity
- Entity to saveversion
- Expected version of the entity before the update- Returns:
- Number of affected rows
-
flush
void flush()Flushes changes made to the entities, meaning any change will be persisted.
-