Inflearn Community Q&A
쿼리 데이터 조회가 안됩니다 ㅠㅠ..
Written on
·
317
0
비슷한 예제로 계시판을 하나 만들었는데,
콘솔에 나온 쿼리로 db에 쿼리 조회를 하면 조회가 되는데
콘솔에서는 값이 null이라고 나오네요 ㅠㅠ..
뭔지 모르겠습니다 ㅠㅠ..



Quiz
QuerydslPredicateExecutor 인터페이스의 주요 한계는 무엇일까요?
기본 검색 불가
조인 및 복잡한 조건 처리 어려움
페이징 지원 부족
스프링 데이터 JPA와 충돌
Answer 3
0
안녕하세요. 박태규님
2가지 문제가 있습니다.
문제1
문제가 있는 코드
pictureService를 의존관계 주입받지 않습니다. 따라서 null 예외가 발생합니다.
public class PostRepositoryImpl implements PostRepositoryCustom{
private final JPAQueryFactory queryFactory;
public PostRepositoryImpl(EntityManager em){
this.queryFactory = new JPAQueryFactory(em);
}
public PictureService pictureService;
해결 코드
public class PostRepositoryImpl implements PostRepositoryCustom{
private final JPAQueryFactory queryFactory;
private final PictureService pictureService;
public PostRepositoryImpl(EntityManager em, PictureService pictureService){
this.queryFactory = new JPAQueryFactory(em);
this.pictureService = pictureService;
}
문제2
문제가 있는 코드
코드를 보시면 postId가 자기 자신을 입력하고 있습니다. 파라미터로 넘어오는 PostId는 대문자 입니다.
@QueryProjection
public PostListDto(Long memberId, Long PostId, String title){
this.memberId = memberId;
this.postId = postId;
this.title = title;
}
해결 코드
@QueryProjection
public PostListDto(Long memberId, Long PostId, String title){
this.memberId = memberId;
// this.postId = postId;
this.postId = PostId;
this.title = title;
}
감사합니다.
0
구글 공유 링크 남깁니다.
https://drive.google.com/file/d/1uRcFTFIRd3F5WrPSvMeYROv9THEBtQyI/view?usp=sharing
>> 방법 입니다.
1. member insert - 하단의 url로 post날립니다.
post : http://localhost:8080/api/member/join
0
안녕하세요. 박태규님
전체 프로젝트를 압축해서 구글 드라이브로 공유해서 링크를 남겨주세요.
구글 드라이브 업로드 방법은 다음을 참고해주세요.
주의: 업로드시 링크에 있는 권한 문제 꼭 확인해주세요
추가로 다음 내용도 코멘트 부탁드립니다.
1. 실행 방법을 알려주세요.
2. 어떻게 문제를 확인할 수 있는지 자세한 설명을 남겨주세요.
감사합니다.





