-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
QuerydslJpaRepository가 depreacted 됬는데요
19.11.04 22:55 작성 조회수 316
0
QuerydslJpaPredicateExecutor 를 쓰라고 해서
이것으로 바꿔봤는데요 JpaRepository 의 모든
메소드를 오버라이딩 해야 하는식으로 되버려서
어떻게 적용하면 좋을지 질문드려 봅니다.
답변을 작성해보세요.
0
백기선
지식공유자2019.11.05
아 커스텀 베이스 리파지토리까지 만들어 쓰시는 경우로군요. 이 경우는 좀 더 복잡한데...
https://stackoverflow.com/questions/53083047/replacing-deprecated-querydsljparepository-with-querydsljpapredicateexecutor-fai
여기에 예제 코드가 나와있으니 참고하세요.
0
김태형
질문자2019.11.05
안녕하세요. 답변 감사드립니다.
예제에 있던 MyRepository 를
@NoRepositoryBean
public interface MyRepository<T, ID extends Serializable> extends JpaRepository<T, ID>, QuerydslPredicateExecutor<T> {
boolean contains(T entity);
}
위와 같이 바꿨습니다.
그리고 이를 사용하는 SimpleMyRepository 에서
public class SimpleMyRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements MyRepository<T, ID> {
private EntityManager entityManager;
public SimpleMyRepository(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager, EntityManager entityManager1) {
super(entityInformation, entityManager);
this.entityManager = entityManager1;
}
@Override
public boolean contains(T entity) {
return entityManager.contains(entity);
}
}
위와 같이 바꾸려는데 JpaRepository는 구현체인 SimpleJpaRepository 가 있는 반면,
QuerydslPredicateExecutor 은 구현체가 없어서
위 함수들을 재정의 해줘야 하는것으로 보입니다.
구현체인 QuerydslJpaPredicateExecutor 를 SimpleMyRepository 에서 상속해야 할 것 같은데
하나만 상속이 되니 어떻게 해야 할지 잘 모르겠습니다.
0
백기선
지식공유자2019.11.05
QuerydslPredicateExecutor 이 인터페이스를 JpaRepository를 extends한 인터페이스에 추가로 extends 해주시면 finallAll(Predicate)등, QueryDSL과 연동한 구현체를 제공해 줍니다.
MyRepo extends JpaRpository<E, K>, QuerydslPredicateExecutor<E>
이런식으로요.
답변 3