Interface NotificationRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Notification,Integer>, org.springframework.data.jpa.repository.JpaRepository<Notification,Integer>, org.springframework.data.repository.ListCrudRepository<Notification,Integer>, org.springframework.data.repository.ListPagingAndSortingRepository<Notification,Integer>, org.springframework.data.repository.PagingAndSortingRepository<Notification,Integer>, org.springframework.data.repository.query.QueryByExampleExecutor<Notification>, org.springframework.data.repository.Repository<Notification,Integer>

@Repository public interface NotificationRepository extends org.springframework.data.jpa.repository.JpaRepository<Notification,Integer>
Spring Data JPA repository for Notification entities.

Provides standard CRUD operations as well as custom query methods for retrieving, counting, and marking notifications for a specific recipient.

Author:
SportTrack Team
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Counts the number of unseen notifications for the specified recipient.
    Finds a notification by its identifier and the identifier of its recipient.
    Finds all unseen notifications for the specified recipient, ordered by creation time descending.
    Finds all notifications for the specified recipient, ordered by creation time descending.
    Finds the ten most recent notifications for the specified recipient.
    int
    markAllAsSeen(Integer recipientId)
    Marks all notifications for the specified recipient as seen.

    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

    • findByRecipientIdOrderByCreatedAtDesc

      List<Notification> findByRecipientIdOrderByCreatedAtDesc(Integer recipientId)
      Finds all notifications for the specified recipient, ordered by creation time descending.
      Parameters:
      recipientId - the unique identifier of the recipient
      Returns:
      a list of notifications, newest first
    • findTop10ByRecipientIdOrderByCreatedAtDesc

      List<Notification> findTop10ByRecipientIdOrderByCreatedAtDesc(Integer recipientId)
      Finds the ten most recent notifications for the specified recipient.
      Parameters:
      recipientId - the unique identifier of the recipient
      Returns:
      a list of up to ten notifications, newest first
    • findByRecipientIdAndSeenFalseOrderByCreatedAtDesc

      List<Notification> findByRecipientIdAndSeenFalseOrderByCreatedAtDesc(Integer recipientId)
      Finds all unseen notifications for the specified recipient, ordered by creation time descending.
      Parameters:
      recipientId - the unique identifier of the recipient
      Returns:
      a list of unseen notifications, newest first
    • countByRecipientIdAndSeenFalse

      long countByRecipientIdAndSeenFalse(Integer recipientId)
      Counts the number of unseen notifications for the specified recipient.
      Parameters:
      recipientId - the unique identifier of the recipient
      Returns:
      the count of unseen notifications
    • findByIdAndRecipientId

      Optional<Notification> findByIdAndRecipientId(Integer id, Integer recipientId)
      Finds a notification by its identifier and the identifier of its recipient.
      Parameters:
      id - the unique identifier of the notification
      recipientId - the unique identifier of the recipient
      Returns:
      an Optional containing the notification if found, empty otherwise
    • markAllAsSeen

      @Modifying @Query("UPDATE Notification n SET n.seen = true WHERE n.recipient.id = :recipientId") int markAllAsSeen(@Param("recipientId") Integer recipientId)
      Marks all notifications for the specified recipient as seen.
      Parameters:
      recipientId - the unique identifier of the recipient whose notifications should be marked
      Returns:
      the number of notifications that were updated