Ignore:
Timestamp:
02/09/22 15:46:58 (3 years ago)
Author:
Test <matonikolov77@…>
Branches:
main
Children:
8f1b7e9
Parents:
967b414
Message:

Refactored reply repository and discussion repository

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  
    77import com.wediscussmovies.project.model.relation.MovieLikes;
    88import com.wediscussmovies.project.model.relation.UserGenres;
     9import org.springframework.data.domain.Sort;
    910import org.springframework.data.jpa.repository.JpaRepository;
    1011import org.springframework.stereotype.Repository;
     
    1516public interface DiscussionLikesRepository extends JpaRepository<DiscussionLikes, DiscussionLikesPK> {
    1617    List<DiscussionLikes> findAllByUser(User user);
     18
    1719}
  • src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java

    r967b414 r6f91f99  
    44import com.wediscussmovies.project.model.Movie;
    55import com.wediscussmovies.project.model.Person;
    6 import com.wediscussmovies.project.querymodels.DiscussionLikes;
    7 import com.wediscussmovies.project.querymodels.GenreLikes;
     6import com.wediscussmovies.project.querymodels.DiscussionLikesQM;
    87import org.springframework.data.jpa.repository.JpaRepository;
    98import org.springframework.data.jpa.repository.Query;
     9import org.springframework.data.repository.query.Param;
    1010import org.springframework.stereotype.Repository;
    1111
     
    1919     List<Discussion> findAllByPerson (Person person);
    2020
    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" +
    2222             " 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"+
    2425             " order by count(dl.id.userId) desc")
    2526     @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();
    2735}
  • src/main/java/com/wediscussmovies/project/repository/GenreLikesRepository.java

    r967b414 r6f91f99  
    22
    33import com.wediscussmovies.project.model.User;
    4 import com.wediscussmovies.project.model.primarykeys.GenreLikesPK;
    5 import com.wediscussmovies.project.model.primarykeys.MovieLikesPK;
    64import com.wediscussmovies.project.model.primarykeys.UserGenresPK;
    7 import com.wediscussmovies.project.model.relation.MovieLikes;
    85import com.wediscussmovies.project.model.relation.UserGenres;
    9 import com.wediscussmovies.project.querymodels.GenreLikes;
    106import org.springframework.data.jpa.repository.JpaRepository;
    117import org.springframework.stereotype.Repository;
  • src/main/java/com/wediscussmovies/project/repository/GenreRepository.java

    r967b414 r6f91f99  
    22
    33import com.wediscussmovies.project.model.Genre;
    4 import com.wediscussmovies.project.querymodels.GenreLikes;
     4import com.wediscussmovies.project.querymodels.GenreLikesQM;
    55import org.springframework.data.jpa.repository.JpaRepository;
    66import org.springframework.data.jpa.repository.Modifying;
     
    1010
    1111import javax.transaction.Transactional;
    12 import java.sql.Date;
    1312import java.util.List;
    1413
     
    1716     List<Genre> findAllByGenreType(String genre);
    1817
    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" +
    2019             " left join UserGenres ug on ug.id.genreId = g.genreId" +
    2120             " 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")
    2322     @Transactional
    24      List<GenreLikes> findAllWithLikes();
     23     List<GenreLikesQM> findAllWithLikes();
    2524
    2625     @Modifying
  • src/main/java/com/wediscussmovies/project/repository/MovieRepository.java

    r967b414 r6f91f99  
    33import com.wediscussmovies.project.model.Movie;
    44import com.wediscussmovies.project.model.Person;
    5 import com.wediscussmovies.project.querymodels.GenreLikes;
    65import com.wediscussmovies.project.querymodels.MovieLikesQM;
    76import org.springframework.data.jpa.repository.JpaRepository;
Note: See TracChangeset for help on using the changeset viewer.