QueryDSL 관련해서 질문드립니다.
229
작성한 질문수 1
안녕하세요. 강의를 듣던 중 테스트가 실패해야하는데 정상적으로 실행이 되어 질문드립니다.
25.스프링 데이터 Common: QueryDSL 에 관련된 질문입니다.
저와 같은 질문을 하신 분이 있던데(https://www.inflearn.com/questions/9020) 버전 변경으로 인해QuerydslJpaRepository 이 deprecated 되며 SimpleJpaRepository 를 변경하지 않고 사용할 repository 에 QuerydslPredicateExecutor 을 상속받아서 사용해도 되는지 문의드립니다.
하단에 코드 함께 첨부하였습니다.
@EnableJpaRepositories(repositoryBaseClass = SimpleMyRepository.class)
@NoRepositoryBean
public interface MyRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {
boolean contains(T entity);
}
public class SimpleMyRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements MyRepository<T, ID>{
private EntityManager entityManager;
private SimpleMyRepository(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
super(entityInformation, entityManager);
this.entityManager = entityManager;
}
@Override
public boolean contains(T entity) {
return entityManager.contains(entity);
}
}
public interface PostRepository extends MyRepository<Post, Long>, QuerydslPredicateExecutor<Post> {
}
@Test
public void crud() {
Post post = new Post();
post.setTitle("hibernate!");
postRepository.save(post.publish());
Predicate predicate = QPost.post.title.contains("hi");
Optional<Post> one = postRepository.findOne(predicate);
assertThat(one).isNotEmpty();
}
답변 1
spring boot 2.7.13-SNAPSHOT trace 소문자 로그 안나옴
0
533
1
<스프링 데이터 Common: 기본 리포지토리 커스터마이징> 에 대한 질문
0
392
1
comment table에서 저장될떄 왜 id값이 2부터저장이되는건가요?
0
407
1
@EnableJpaRepositories 설정을 스프링부트가 어디에서 자동설정하나요?
0
451
0
PersistenceContext 관련 질문드립니다.
0
335
1
지금(Eager), 나중에(Lazy)의 의미를 모르겠습니다
0
338
1
transaction 구간이 길어질 경우의 처리방법 문의드립니다.
0
905
1
docker postgres
0
293
1
Multiple DataSource 사용 시 transaction 관련 질문 드립니다.
0
2908
1
entity 중 null이 아닌 필드만 update 할 방법이 있을까요?
0
1191
1
Eager 모드일 경우, join을 inner join으로 바꾸는 법이 있을까요?
0
385
1
엔티티를 상속받는 DTO가 일반적인가요?
1
1847
1
커스텀 타입 클래스를 String 타입 처럼 이용해 쿼리하는 방법에 대해 질문하고 싶습니다.
0
339
1
연관관계 매핑 어떤식으로 해야될지 감이 안잡힙니다.
0
566
4
EntityManager 주입시 Annotation관련 질문드립니다.
0
565
1
클래스 기반 프로젝션 사용 관련 질문
0
560
1
save 메서드 질문드립니다.
0
258
1
복잡한 통계쿼리도 JPA로 가능한가요?
2
5593
1
find 와 get의 차이가 무엇인가요?
0
890
1
실무에서 JPA 할 때 FK로 개발할때 연관관계를 꼭 맺어주어야 하나요?
0
999
1
\dt Did not find any relations.
0
481
1
소스코드는 어디서 볼 수 있을까요?
1
287
1
table 생성과 select 문에 대한 질문
0
174
1
스프링 데이터 RepositoryTest 관련 질문
0
2173
2





