Changeset e0ef1b1 in Git for src/main/java/com/wediscussmovies/project/repository
- Timestamp:
- 02/04/22 23:22:13 (3 years ago)
- Branches:
- main
- Children:
- 5b447b0
- Parents:
- 3ded84d
- Location:
- src/main/java/com/wediscussmovies/project/repository
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/repository/DiscussionRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model.Discussion; 4 import com.wediscussmovies.project.model.Movie; 5 import com.wediscussmovies.project.model.Person; 3 6 import org.springframework.data.jpa.repository.JpaRepository; 4 7 import org.springframework.stereotype.Repository; 5 8 6 9 import java.util.List; 7 import com.wediscussmovies.project.model.*;8 10 9 11 @Repository 10 12 public interface DiscussionRepository extends JpaRepository<Discussion, Integer> { 11 public List<Discussion> findAllByTitleLike(String title); 13 List<Discussion> findAllByTitleLike(String title); 14 List<Discussion> findAllByMovie(Movie movie); 15 List<Discussion> findAllByPerson (Person person); 12 16 } -
src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model.*; 3 import com.wediscussmovies.project.model.Genre; 4 import com.wediscussmovies.project.querymodels.GenreLikes; 4 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Query; 5 7 import org.springframework.stereotype.Repository; 6 8 9 import javax.transaction.Transactional; 7 10 import java.util.List; 8 11 9 12 @Repository 10 13 public interface GenreRepository extends JpaRepository<Genre, Integer> { 11 public List<Genre> findAllByGenreType(String genre); 14 List<Genre> findAllByGenreType(String genre); 15 16 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreType, count(ug.id.userId)) from Genre g" + 17 " left join UserGenres ug on ug.id.genreId = g.genreId" + 18 " group by g.genreType" + 19 " order by count(ug.id.userId) desc") 20 @Transactional 21 List<GenreLikes> findAllWithLikes(); 12 22 } -
src/main/java/com/wediscussmovies/project/repository/MovieRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model.Movie; 4 import com.wediscussmovies.project.model.Person; 3 5 import org.springframework.data.jpa.repository.JpaRepository; 4 6 import org.springframework.stereotype.Repository; 5 7 6 8 import java.util.List; 7 import com.wediscussmovies.project.model.*;8 9 9 10 @Repository 10 11 public interface MovieRepository extends JpaRepository<Movie, Integer> { 11 public List<Movie> findAllByTitleLike(String Title); 12 List<Movie> findAllByTitleLike(String Title); 13 List<Movie> findAllByDirector(Person director); 14 List<Movie> findAllByDirectorIsNull(); 12 15 } -
src/main/java/com/wediscussmovies/project/repository/PersonRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model.*; 4 import com.wediscussmovies.project.model.enumerations.PersonType; 3 import com.wediscussmovies.project.model.Person; 5 4 import org.springframework.data.jpa.repository.JpaRepository; 6 5 import org.springframework.stereotype.Repository; 7 6 8 7 import java.util.List; 9 import java.util.Optional;10 8 11 9 @Repository 12 10 public interface PersonRepository extends JpaRepository<Person, Integer> { 13 public List<Person> findAllByType(Character type); 14 public List<Person> findAllByTypeAndNameLike(Character type, String name); 15 public List<Person> findAllByTypeAndSurnameLike(Character type, String surname); 16 public Optional<Person> findPersonByPersonIdAndType(Integer id, Character type); 11 List<Person> findAllByType(Character type); 12 List<Person> findAllByTypeAndNameLike(Character type, String name); 13 List<Person> findAllByTypeAndSurnameLike(Character type, String surname); 14 // Optional<Person> findPersonByPersonIdAndType(Integer id, Character type); 15 List<Person> findAllByTypeAndNameLikeOrSurnameLike(Character type,String name, String surname); 17 16 } -
src/main/java/com/wediscussmovies/project/repository/ReplyRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model.Discussion; 4 import com.wediscussmovies.project.model.Reply; 5 import com.wediscussmovies.project.model.primarykeys.ReplyPK; 3 6 import org.springframework.data.jpa.repository.JpaRepository; 7 import org.springframework.data.jpa.repository.Modifying; 8 import org.springframework.data.jpa.repository.Query; 9 import org.springframework.data.repository.query.Param; 4 10 import org.springframework.stereotype.Repository; 5 import com.wediscussmovies.project.model.*; 11 12 import javax.transaction.Transactional; 13 import java.sql.Date; 14 import java.util.List; 6 15 7 16 8 17 @Repository 9 public interface ReplyRepository extends JpaRepository<Reply, Integer> { 18 public interface ReplyRepository extends JpaRepository<Reply, ReplyPK> { 19 List<Reply> findAllByDiscussion(Discussion discussion); 20 21 @Modifying 22 @Query(value = "insert into project.replies (text,date,user_id,discussion_id) values(:text,:date,:user_id,:discussion_id)",nativeQuery = true) 23 @Transactional 24 void insertInto(@Param("text") String text, @Param("date")Date date, 25 @Param("user_id")Integer userId,@Param("discussion_id")Integer discussionId); 10 26 } -
src/main/java/com/wediscussmovies/project/repository/UserRepository.java
r3ded84d re0ef1b1 1 1 package com.wediscussmovies.project.repository; 2 2 3 import com.wediscussmovies.project.model. *;3 import com.wediscussmovies.project.model.User; 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 5 import org.springframework.stereotype.Repository; … … 9 9 @Repository 10 10 public interface UserRepository extends JpaRepository<User, Integer> { 11 public Optional<User> findByEmailAndPassword(String email, String password); 12 public Optional<User> findByUsernameAndPassword(String email, String password); 13 public Optional<User> findByUsername(String username); 14 public Optional<User> findByEmail(String email); 11 Optional<User> findByUsername(String username); 15 12 }
Note:
See TracChangeset
for help on using the changeset viewer.