Changeset 3c0f9a9 in Git for src/main/java/com/wediscussmovies/project/repository
- Timestamp:
- 02/07/22 19:57:58 (3 years ago)
- Branches:
- main
- Children:
- ad4243e, c02189f
- Parents:
- 7f36551
- Location:
- src/main/java/com/wediscussmovies/project/repository
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
r7f36551 r3c0f9a9 4 4 import com.wediscussmovies.project.querymodels.GenreLikes; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Modifying; 6 7 import org.springframework.data.jpa.repository.Query; 8 import org.springframework.data.repository.query.Param; 7 9 import org.springframework.stereotype.Repository; 8 10 9 11 import javax.transaction.Transactional; 12 import java.sql.Date; 10 13 import java.util.List; 11 14 … … 14 17 List<Genre> findAllByGenreType(String genre); 15 18 16 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genre Type, count(ug.id.userId)) from Genre g" +19 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreId, g.genreType, count(ug.id.userId)) from Genre g" + 17 20 " left join UserGenres ug on ug.id.genreId = g.genreId" + 18 " group by g.genre Type" +21 " group by g.genreId, g.genreType" + 19 22 " order by count(ug.id.userId) desc") 20 23 @Transactional 21 24 List<GenreLikes> findAllWithLikes(); 25 26 @Modifying 27 @Query(value = "insert into project.user_genres (user_id,genre_id) values(:user_id,:genre_id)",nativeQuery = true) 28 @Transactional 29 void insertInto(@Param("user_id")Integer userId, @Param("genre_id")Integer genreId); 22 30 } -
src/main/java/com/wediscussmovies/project/repository/MovieRepository.java
r7f36551 r3c0f9a9 4 4 import com.wediscussmovies.project.model.Person; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Query; 6 7 import org.springframework.stereotype.Repository; 7 8 … … 13 14 List<Movie> findAllByDirector(Person director); 14 15 List<Movie> findAllByDirectorIsNull(); 16 @Query(value="select m.movieId from Movie m") 17 List<Integer> findAllMovieIds(); 15 18 }
Note:
See TracChangeset
for help on using the changeset viewer.