Interface UserFavoriteArtistRepository

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

public interface UserFavoriteArtistRepository extends org.springframework.data.jpa.repository.JpaRepository<UserFavoriteArtist,UUID>
Repository for UserFavoriteArtist entities.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFavoriteArtist(@NotNull UUID userId, @NotNull UUID artistId)
    Adds a favorite artist for a user.
    Counts the number of favorite artists created between two timestamps.
    Finds all of a user's favorite artists.
    Finds a user's favorite artist by user and artist.
    org.springframework.data.domain.Page<UserFavoriteArtist>
    findByUserId(UUID userId, org.springframework.data.domain.Pageable pageable)
    Finds a page of a user's favorite artists.
    findByUserIdAndArtistId(UUID userId, UUID artistId)
    Finds a user's favorite artist by user ID and artist ID.
    Finds the most recently created favorite artist relationship.

    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

    • findByUserAndArtist

      Optional<UserFavoriteArtist> findByUserAndArtist(User user, Artist artist)
      Finds a user's favorite artist by user and artist.
      Parameters:
      user - The user.
      artist - The artist.
      Returns:
      An optional containing the user's favorite artist if found, otherwise empty.
    • findByUserIdAndArtistId

      Optional<UserFavoriteArtist> findByUserIdAndArtistId(UUID userId, UUID artistId)
      Finds a user's favorite artist by user ID and artist ID.
      Parameters:
      userId - The ID of the user.
      artistId - The ID of the artist.
      Returns:
      An optional containing the user's favorite artist if found, otherwise empty.
    • findByUserId

      org.springframework.data.domain.Page<UserFavoriteArtist> findByUserId(UUID userId, org.springframework.data.domain.Pageable pageable)
      Finds a page of a user's favorite artists.
      Parameters:
      userId - The ID of the user.
      pageable - The pageable request.
      Returns:
      A page of user favorite artists.
    • findAllByUserId

      List<UserFavoriteArtist> findAllByUserId(UUID userId)
      Finds all of a user's favorite artists.
      Parameters:
      userId - The ID of the user.
      Returns:
      A list of user favorite artists.
    • addFavoriteArtist

      @Modifying @Query(value="insert into user_favorite_artists (user_id, artist_id, created_at) values (:userId, :artistId, current_timestamp) on conflict do nothing", nativeQuery=true) void addFavoriteArtist(@NotNull @NotNull UUID userId, @NotNull @NotNull UUID artistId)
      Adds a favorite artist for a user.
      Parameters:
      userId - The ID of the user.
      artistId - The ID of the artist.
    • countByCreatedAtBetween

      @Async CompletableFuture<Long> countByCreatedAtBetween(Instant start, Instant end)
      Counts the number of favorite artists created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of favorite artists.
    • findTopByOrderByCreatedAt

      UserFavoriteArtist findTopByOrderByCreatedAt()
      Finds the most recently created favorite artist relationship.
      Returns:
      The user favorite artist.