Changeset 6f91f99 in Git for src/main/java/com/wediscussmovies/project/repository
- Timestamp:
- 02/09/22 15:46:58 (3 years ago)
- Branches:
- main
- Children:
- 8f1b7e9
- Parents:
- 967b414
- Location:
- src/main/java/com/wediscussmovies/project/repository
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/repository/DiscussionLikesRepository.java
r967b414 r6f91f99 7 7 import com.wediscussmovies.project.model.relation.MovieLikes; 8 8 import com.wediscussmovies.project.model.relation.UserGenres; 9 import org.springframework.data.domain.Sort; 9 10 import org.springframework.data.jpa.repository.JpaRepository; 10 11 import org.springframework.stereotype.Repository; … … 15 16 public interface DiscussionLikesRepository extends JpaRepository<DiscussionLikes, DiscussionLikesPK> { 16 17 List<DiscussionLikes> findAllByUser(User user); 18 17 19 } -
src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java
r967b414 r6f91f99 4 4 import com.wediscussmovies.project.model.Movie; 5 5 import com.wediscussmovies.project.model.Person; 6 import com.wediscussmovies.project.querymodels.DiscussionLikes; 7 import com.wediscussmovies.project.querymodels.GenreLikes; 6 import com.wediscussmovies.project.querymodels.DiscussionLikesQM; 8 7 import org.springframework.data.jpa.repository.JpaRepository; 9 8 import org.springframework.data.jpa.repository.Query; 9 import org.springframework.data.repository.query.Param; 10 10 import org.springframework.stereotype.Repository; 11 11 … … 19 19 List<Discussion> findAllByPerson (Person person); 20 20 21 @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikes (d.discussionId, count(dl.id.userId)) from Discussion d" +21 @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM(d.discussionId, count(dl.id.userId)) from Discussion d" + 22 22 " left join DiscussionLikes dl on dl.id.discussionId = d.discussionId" + 23 " group by d.discussionId" + 23 " where :discussionId = d.discussionId" + 24 " group by d.discussionId"+ 24 25 " order by count(dl.id.userId) desc") 25 26 @Transactional 26 List<DiscussionLikes> findAllWithLikes(); 27 DiscussionLikesQM findDiscussionWithLikes(@Param("discussionId") Integer discussionId); 28 29 @Query(value = "select new com.wediscussmovies.project.querymodels.DiscussionLikesQM(d.discussionId, count(dl.id.userId)) from Discussion d" + 30 " left join DiscussionLikes dl on dl.id.discussionId = d.discussionId" + 31 " group by d.discussionId"+ 32 " order by count(dl.id.userId) desc") 33 @Transactional 34 List<DiscussionLikesQM> findAllDiscussionsWithLikes(); 27 35 } -
src/main/java/com/wediscussmovies/project/repository/GenreLikesRepository.java
r967b414 r6f91f99 2 2 3 3 import com.wediscussmovies.project.model.User; 4 import com.wediscussmovies.project.model.primarykeys.GenreLikesPK;5 import com.wediscussmovies.project.model.primarykeys.MovieLikesPK;6 4 import com.wediscussmovies.project.model.primarykeys.UserGenresPK; 7 import com.wediscussmovies.project.model.relation.MovieLikes;8 5 import com.wediscussmovies.project.model.relation.UserGenres; 9 import com.wediscussmovies.project.querymodels.GenreLikes;10 6 import org.springframework.data.jpa.repository.JpaRepository; 11 7 import org.springframework.stereotype.Repository; -
src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
r967b414 r6f91f99 2 2 3 3 import com.wediscussmovies.project.model.Genre; 4 import com.wediscussmovies.project.querymodels.GenreLikes ;4 import com.wediscussmovies.project.querymodels.GenreLikesQM; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 6 import org.springframework.data.jpa.repository.Modifying; … … 10 10 11 11 import javax.transaction.Transactional; 12 import java.sql.Date;13 12 import java.util.List; 14 13 … … 17 16 List<Genre> findAllByGenreType(String genre); 18 17 19 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes (g.genreId, g.genreType, count(ug.id.userId)) from Genre g" +18 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikesQM(g.genreId, g.genreType, count(ug.id.userId)) from Genre g" + 20 19 " left join UserGenres ug on ug.id.genreId = g.genreId" + 21 20 " group by g.genreId, g.genreType" + 22 " order by count(ug.id.userId) desc ")21 " order by count(ug.id.userId) desc, g.genreType asc") 23 22 @Transactional 24 List<GenreLikes > findAllWithLikes();23 List<GenreLikesQM> findAllWithLikes(); 25 24 26 25 @Modifying -
src/main/java/com/wediscussmovies/project/repository/MovieRepository.java
r967b414 r6f91f99 3 3 import com.wediscussmovies.project.model.Movie; 4 4 import com.wediscussmovies.project.model.Person; 5 import com.wediscussmovies.project.querymodels.GenreLikes;6 5 import com.wediscussmovies.project.querymodels.MovieLikesQM; 7 6 import org.springframework.data.jpa.repository.JpaRepository;
Note:
See TracChangeset
for help on using the changeset viewer.