Interface RecycleBinDriveRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<RecycleBinDriveEntity, Long>, org.springframework.data.jpa.repository.JpaRepository<RecycleBinDriveEntity, Long>, org.springframework.data.repository.ListCrudRepository<RecycleBinDriveEntity, Long>, org.springframework.data.repository.ListPagingAndSortingRepository<RecycleBinDriveEntity, Long>, org.springframework.data.repository.PagingAndSortingRepository<RecycleBinDriveEntity, Long>, org.springframework.data.repository.query.QueryByExampleExecutor<RecycleBinDriveEntity>, org.springframework.data.repository.Repository<RecycleBinDriveEntity, Long>
public interface RecycleBinDriveRepository
extends org.springframework.data.jpa.repository.JpaRepository<RecycleBinDriveEntity, Long>
-
Method Summary
Modifier and TypeMethodDescriptionintaddToTotals(long ownerId, long size, long count, Date updatedDate) Adds to the totals of a drive, in the database: the stored values are not read first.intdeleteByOwner(long ownerId) Deletes the row of a drive, whatever it counts.intdeleteWhenEmpty(long ownerId) Deletes the row of a drive whose bin holds no item any more.findAllBy(org.springframework.data.domain.Pageable pageable) Reads a page of drives without counting them all.intCreates the row of a drive.intWrites the totals of a drive in place of the stored ones.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findAllBy
Reads a page of drives without counting them all. -
addToTotals
@Modifying(flushAutomatically=true, clearAutomatically=true) @Query("UPDATE RecycleBinDrive d\n SET d.itemsSize = d.itemsSize + :size,\n d.itemsCount = d.itemsCount + :count,\n d.updatedDate = :updatedDate\n WHERE d.ownerId = :ownerId\n") int addToTotals(@Param("ownerId") long ownerId, @Param("size") long size, @Param("count") long count, @Param("updatedDate") Date updatedDate) Adds to the totals of a drive, in the database: the stored values are not read first. Negative values subtract.- Returns:
- the number of rows changed, 0 when the drive has no row
-
insert
@Modifying(flushAutomatically=true, clearAutomatically=true) @Query("INSERT INTO RecycleBinDrive (ownerId, itemsSize, itemsCount, updatedDate)\nVALUES (:ownerId, :size, :count, :updatedDate)\n") int insert(@Param("ownerId") long ownerId, @Param("size") long size, @Param("count") long count, @Param("updatedDate") Date updatedDate) Creates the row of a drive. A drive that already has one is refused by the primary key: the row is never replaced. -
deleteWhenEmpty
@Modifying(flushAutomatically=true, clearAutomatically=true) @Query("DELETE FROM RecycleBinDrive d WHERE d.ownerId = :ownerId AND d.itemsCount <= 0") int deleteWhenEmpty(@Param("ownerId") long ownerId) Deletes the row of a drive whose bin holds no item any more.- Returns:
- the number of rows deleted
-
setTotals
@Modifying(flushAutomatically=true, clearAutomatically=true) @Query("UPDATE RecycleBinDrive d\n SET d.itemsSize = :size,\n d.itemsCount = :count,\n d.updatedDate = :updatedDate\n WHERE d.ownerId = :ownerId\n") int setTotals(@Param("ownerId") long ownerId, @Param("size") long size, @Param("count") long count, @Param("updatedDate") Date updatedDate) Writes the totals of a drive in place of the stored ones.- Returns:
- the number of rows changed, 0 when the drive has no row
-
findOwnerIds
-
deleteByOwner
@Modifying(flushAutomatically=true, clearAutomatically=true) @Query("DELETE FROM RecycleBinDrive d WHERE d.ownerId = :ownerId") int deleteByOwner(@Param("ownerId") long ownerId) Deletes the row of a drive, whatever it counts.- Returns:
- the number of rows deleted
-