Interface ArticleRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Article,Long>, org.springframework.data.jpa.repository.JpaRepository<@NonNull Article,@NonNull Long>, org.springframework.data.repository.ListCrudRepository<Article,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<Article,Long>, org.springframework.data.repository.PagingAndSortingRepository<Article,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Article>, org.springframework.data.repository.Repository<Article,Long>

@Repository public interface ArticleRepository extends org.springframework.data.jpa.repository.JpaRepository<@NonNull Article,@NonNull Long>
The ArticleRepository provides database access for Article entities.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of articles related to the event with the given ID.
    org.springframework.data.domain.Page<Article>
    findAllByOrderByPublishedDateDesc(@NonNull org.springframework.data.domain.Pageable pageable)
    Returns a Page of all articles ordered by their published date descending.
    org.springframework.data.domain.Page<Article>
    findByAthleteId(Long athleteId, @NonNull org.springframework.data.domain.Pageable pageable)
    Returns a Page of articles authored by the athlete with the given ID, ordered by published date descending.
    org.springframework.data.domain.Page<Article>
    findByEventId(Long eventId, @NonNull org.springframework.data.domain.Pageable pageable)
    Returns a Page of articles associated with a given event ID.
    Returns a List of all published articles (i.e. with a non-null published date), ordered by their published date descending.
    Finds an Article by its unique URL slug.

    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

    • countByEventId

      @Query("SELECT COUNT(DISTINCT a) FROM Article a JOIN a.relatedEvents e WHERE e.id = :eventId") long countByEventId(@Param("eventId") Long eventId)
      Returns the number of articles related to the event with the given ID.
      Parameters:
      eventId - the ID of the Event
      Returns:
      the number of articles related to the given event (0 if none)
    • findAllByOrderByPublishedDateDesc

      org.springframework.data.domain.Page<Article> findAllByOrderByPublishedDateDesc(@NonNull org.springframework.data.domain.Pageable pageable)
      Returns a Page of all articles ordered by their published date descending.
      Parameters:
      pageable - the pagination information
      Returns:
      a Page of articles ordered by published date descending
    • findByAthleteId

      @Query("SELECT DISTINCT a FROM Article a JOIN a.author au JOIN au.athlete at WHERE at.id = :athleteId ORDER BY a.publishedDate DESC") org.springframework.data.domain.Page<Article> findByAthleteId(@Param("athleteId") Long athleteId, @NonNull org.springframework.data.domain.Pageable pageable)
      Returns a Page of articles authored by the athlete with the given ID, ordered by published date descending.
      Parameters:
      athleteId - the ID of the Athlete
      pageable - the pagination information
      Returns:
      a Page of articles authored by the given athlete
    • findByEventId

      @Query("SELECT DISTINCT a FROM Article a JOIN a.relatedEvents e WHERE e.id = :eventId") org.springframework.data.domain.Page<Article> findByEventId(@Param("eventId") Long eventId, @NonNull org.springframework.data.domain.Pageable pageable)
      Returns a Page of articles associated with a given event ID.
      Parameters:
      eventId - the ID of the Event
      pageable - the pagination information
      Returns:
      a Page of articles associated with the given event
    • findByPublishedDateIsNotNullOrderByPublishedDateDesc

      List<Article> findByPublishedDateIsNotNullOrderByPublishedDateDesc()
      Returns a List of all published articles (i.e. with a non-null published date), ordered by their published date descending.
      Returns:
      a List of published articles ordered by published date descending
    • findBySlug

      Optional<Article> findBySlug(String slug)
      Finds an Article by its unique URL slug.
      Parameters:
      slug - the URL slug of the Article
      Returns:
      an Optional containing the Article if found, or empty if not found