Interface ActivityRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Activity,,Integer> org.springframework.data.jpa.repository.JpaRepository<Activity,,Integer> org.springframework.data.repository.ListCrudRepository<Activity,,Integer> org.springframework.data.repository.ListPagingAndSortingRepository<Activity,,Integer> org.springframework.data.repository.PagingAndSortingRepository<Activity,,Integer> org.springframework.data.repository.query.QueryByExampleExecutor<Activity>,org.springframework.data.repository.Repository<Activity,Integer>
@Repository
public interface ActivityRepository
extends org.springframework.data.jpa.repository.JpaRepository<Activity,Integer>
Spring Data JPA repository for
Activity entities.
Provides standard CRUD operations as well as custom query methods for retrieving activities by creator, sport, and date range.
- Author:
- SportTrack Team
-
Method Summary
Modifier and TypeMethodDescriptionbooleanexistsByIdAndCreatedBy_Id(Integer id, Integer athleteId) Checks whether an activity with the given identifier was created by the specified athlete.findActivitiesForChallengeRanking(List<Integer> athleteIds, Integer sportId, LocalDate startDate, LocalDate endDate) Finds activities matching the criteria for challenge ranking computation.findByCreatedBy_IdInOrderByDateADescStartTimeDesc(List<Integer> athleteIds) Finds all activities created by any of the specified athletes, ordered by date and start time descending.Finds all activities created by a specific athlete, ordered by date and start time descending.findByIdAndCreatedBy_Id(Integer id, Integer athleteId) Finds a single activity by its identifier and the identifier of the athlete who created it.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
-
findByCreatedBy_IdOrderByDateADescStartTimeDesc
Finds all activities created by a specific athlete, ordered by date and start time descending.- Parameters:
athleteId- the unique identifier of the athlete who created the activities- Returns:
- a list of matching activities, newest first
-
findByCreatedBy_IdInOrderByDateADescStartTimeDesc
Finds all activities created by any of the specified athletes, ordered by date and start time descending.- Parameters:
athleteIds- the list of athlete identifiers whose activities should be retrieved- Returns:
- a list of matching activities, newest first
-
findActivitiesForChallengeRanking
@Query("SELECT a\nFROM Activity a\nWHERE a.createdBy.id IN :athleteIds\n AND a.sportAndType.id = :sportId\n AND a.dateA BETWEEN :startDate AND :endDate\n") List<Activity> findActivitiesForChallengeRanking(@Param("athleteIds") List<Integer> athleteIds, @Param("sportId") Integer sportId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate) Finds activities matching the criteria for challenge ranking computation. Returns activities performed by the given athletes, for the specified sport, within the given date range.- Parameters:
athleteIds- the identifiers of the athletes whose activities should be consideredsportId- the identifier of the sport to filter bystartDate- the inclusive start date of the rangeendDate- the inclusive end date of the range- Returns:
- a list of matching activities
-
findByIdAndCreatedBy_Id
Finds a single activity by its identifier and the identifier of the athlete who created it.- Parameters:
id- the activity identifierathleteId- the creator's identifier- Returns:
- an
Optionalcontaining the activity if found, empty otherwise
-
existsByIdAndCreatedBy_Id
Checks whether an activity with the given identifier was created by the specified athlete.- Parameters:
id- the activity identifierathleteId- the creator's identifier- Returns:
trueif such an activity exists,falseotherwise
-