Package org.localify.repositories
Interface GenreRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Genre,,UUID> org.springframework.data.repository.Repository<Genre,UUID>
@Repository
public interface GenreRepository
extends org.springframework.data.repository.CrudRepository<Genre,UUID>
Repository for
Genre entities.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe minimum score for a genre to be considered a top genre for an artist. -
Method Summary
Modifier and TypeMethodDescriptionfindByNameNative(String name) Finds a genre by name using a native query.getTopGenresForArtist(UUID artistId, double minScore, org.springframework.data.domain.Pageable pageable) Gets the top genres for an artist with a minimum score.getTopGenresForArtist(UUID artistId, org.springframework.data.domain.Pageable pageable) Gets the top genres for an artist.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll
-
Field Details
-
MIN_GENRE_SCORE
static final double MIN_GENRE_SCOREThe minimum score for a genre to be considered a top genre for an artist.- See Also:
-
-
Method Details
-
findByNameNative
@Query(value="select * from genres where name ilike :name limit 1", nativeQuery=true) Optional<Genre> findByNameNative(String name) Finds a genre by name using a native query.- Parameters:
name- The name of the genre.- Returns:
- An optional containing the genre if found, otherwise empty.
-
getTopGenresForArtist
@Query("select ag.genre from ArtistGenre ag where ag.artist.id = :artistId and ag.score >= :minScore order by ag.score desc") List<Genre> getTopGenresForArtist(UUID artistId, double minScore, org.springframework.data.domain.Pageable pageable) Gets the top genres for an artist with a minimum score.- Parameters:
artistId- The ID of the artist.minScore- The minimum score.pageable- The pageable request.- Returns:
- A list of genres.
-
getTopGenresForArtist
default List<Genre> getTopGenresForArtist(UUID artistId, org.springframework.data.domain.Pageable pageable) Gets the top genres for an artist.- Parameters:
artistId- The ID of the artist.pageable- The pageable request.- Returns:
- A list of genres.
-