From 9388728babc40a8c64428ce616abce0d75b4ffea Mon Sep 17 00:00:00 2001 From: "michael.breu" <michael.breu@uibk.ac.at> Date: Tue, 20 Apr 2021 20:43:29 +0200 Subject: [PATCH] Fixing compilation --- .../repository/WatchListEntryRepository.java | 16 +++++++++++++--- .../gitsearch/service/WatchListEntryService.java | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/ac/uibk/gitsearch/repository/WatchListEntryRepository.java b/src/main/java/at/ac/uibk/gitsearch/repository/WatchListEntryRepository.java index 4678b4ed6..b20af840b 100644 --- a/src/main/java/at/ac/uibk/gitsearch/repository/WatchListEntryRepository.java +++ b/src/main/java/at/ac/uibk/gitsearch/repository/WatchListEntryRepository.java @@ -1,14 +1,24 @@ package at.ac.uibk.gitsearch.repository; -import at.ac.uibk.gitsearch.domain.WatchListEntry; +import java.util.List; -import org.springframework.data.jpa.repository.*; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import at.ac.uibk.gitsearch.domain.WatchListEntry; + /** * Spring Data repository for the WatchListEntry entity. */ -@SuppressWarnings("unused") @Repository public interface WatchListEntryRepository extends JpaRepository<WatchListEntry, Long> { + + @Query("SELECT wle FROM WatchListEntry wle WHERE wle.watchlist.id=:watchListId") + public List<WatchListEntry> getEntriesByWatchlist(@Param("watchListId") Long watchListId); + + @Query("SELECT wle FROM WatchListEntry wle WHERE wle.watchlist.id=:watchListId AND wle.exerciseId=:exerciseId ") + public List<WatchListEntry> getEntriesByWatchlistAndExerciseId(@Param("watchListId") Long watchListId, @Param("exerciseId") String exerciseId); + } diff --git a/src/main/java/at/ac/uibk/gitsearch/service/WatchListEntryService.java b/src/main/java/at/ac/uibk/gitsearch/service/WatchListEntryService.java index 08ed39766..84a623305 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/WatchListEntryService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/WatchListEntryService.java @@ -105,7 +105,7 @@ public class WatchListEntryService { * @param id the id of the entity. */ public void deleteInWatchlist(Long watchListId, String exerciseId) { - final List<WatchListEntry> entries = watchListEntryRepository.getEntriesbyWatchlistAndExerciseId(watchListId, exerciseId); + final List<WatchListEntry> entries = watchListEntryRepository.getEntriesByWatchlistAndExerciseId(watchListId, exerciseId); entries.forEach(en -> delete(en.getId())); } /** @@ -131,7 +131,7 @@ public class WatchListEntryService { */ @Transactional(readOnly = true) public List<WatchListEntryDTO> getEntriesForWatchlist(Long watchlistId) { - return watchListEntryMapper.toDto(watchListEntryRepository.getEntriesbyWatchlist(watchlistId)); + return watchListEntryMapper.toDto(watchListEntryRepository.getEntriesByWatchlist(watchlistId)); } } -- GitLab