-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommentRepo.java
32 lines (26 loc) · 1.18 KB
/
CommentRepo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package io.github.cepr0.projections.repo;
import io.github.cepr0.projections.model.Comment;
import io.github.cepr0.projections.projection.CommentProjection;
import io.github.cepr0.projections.projection.ICommentProjection;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
/**
* @author Sergei Poznanski, 2017-09-22
*/
@SuppressWarnings("SpringDataRepositoryMethodReturnTypeInspection")
public interface CommentRepo extends JpaRepository<Comment, Integer> {
// doesn't work in SB 1.5.x - throw NoSuchElementException
<T> Optional<T> findByUserName(String name, Class<T> type);
<T> Page<T> getAllByTextLike(Pageable pageable, String text, Class<T> type);
<T> Stream<T> findStreamByTextLike(String text, Class<T> type);
// work
<T> T findByText(String text, Class<T> type);
<T> List<T> findAllByTextLike(String text, Class<T> type);
Optional<CommentProjection> findByUserName(String name);
Optional<ICommentProjection> getByUserName(String name);
Optional<Comment> findCommentByUserName(String name);
}