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 Type
    Method
    Description
    int
    addToTotals(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.
    int
    deleteByOwner(long ownerId)
    Deletes the row of a drive, whatever it counts.
    int
    deleteWhenEmpty(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.
     
    int
    insert(long ownerId, long size, long count, Date updatedDate)
    Creates the row of a drive.
    int
    setTotals(long ownerId, long size, long count, Date updatedDate)
    Writes 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, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findAllBy

      List<RecycleBinDriveEntity> findAllBy(org.springframework.data.domain.Pageable pageable)
      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

      @Query("SELECT d.ownerId FROM RecycleBinDrive d") List<Long> findOwnerIds()
      Returns:
      the owners of the drives that have a row
    • 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