qdsl 작업중
This commit is contained in:
14
README.md
14
README.md
@@ -63,6 +63,7 @@ https://www.jiniaslog.co.kr/
|
||||
- Spring Data JPA
|
||||
- Mybatis
|
||||
- EhCache
|
||||
- Qdsl
|
||||
|
||||
#### Build tool
|
||||
- Gradle
|
||||
@@ -139,6 +140,19 @@ https://www.jiniaslog.co.kr/
|
||||
|
||||
## 핵심 기능
|
||||
|
||||
### JPQL로 작성된 기존 쿼리 Qdsl로 스택 마이그레이션
|
||||
|
||||
(진행중)
|
||||
|
||||
기존에는 JPA 메서드 쿼리와 JPQL, 그리고 마이바티스를 사용해 영속성 계층을 구현했습니다. 그중 JPQL은 String 기반으로 작성되어
|
||||
|
||||
컴파일단계에서 에러검증이 되지 않으며, 동적 쿼리 작성에 어려움이 있던 단점이 있었고 실제로 동적 쿼리를 작성하지 못해
|
||||
|
||||
두가지 메서드 쿼리를 분기처리하는 방식으로 구현한 코드도 존재했습니다.
|
||||
|
||||
Qdsl을 학습후 기존 JPQL을 걷어내고 Qdsl로 스택 마이그레이션을 진행하는 중입니다.
|
||||
|
||||
|
||||
### 헥사고날 아키텍처로 리아키텍처링
|
||||
(2022-03-27 추가)
|
||||
|
||||
|
||||
@@ -6,15 +6,13 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ArticleTagListsRepository extends JpaRepository<ArticleTagList, Long> {
|
||||
public interface JpaArticleTagListsRepository extends JpaRepository<ArticleTagList, Long> {
|
||||
|
||||
/*
|
||||
- 아티클 연관 태그 삭제 쿼리
|
||||
- cascade 필요시에는 아티클 삭제로 일괄 삭제하므로 해당쿼리는 연관태그 수정용
|
||||
*/
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("delete from ArticleTagList t " +
|
||||
"where t.article =:article")
|
||||
@@ -4,6 +4,7 @@ import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import myblog.blog.article.domain.Article;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,7 +17,7 @@ public class QdslArticleRepository {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
List<Article> findByOrderByIdDesc(Long articleId, int size){
|
||||
List<Article> findByOrderByIdDesc(Long articleId, int size) {
|
||||
return queryFactory
|
||||
.selectFrom(article)
|
||||
.where(cursorLt(articleId))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package myblog.blog.article.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import myblog.blog.article.adapter.outgoing.persistence.ArticleTagListsRepository;
|
||||
import myblog.blog.article.adapter.outgoing.persistence.JpaArticleTagListsRepository;
|
||||
import myblog.blog.article.adapter.outgoing.persistence.JpaTagsRepository;
|
||||
import myblog.blog.article.application.port.incomming.TagUseCase;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,7 +17,7 @@ import java.util.*;
|
||||
@RequiredArgsConstructor
|
||||
public class TagsService implements TagUseCase {
|
||||
private final JpaTagsRepository jpaTagsRepository;
|
||||
private final ArticleTagListsRepository articleTagListsRepository;
|
||||
private final JpaArticleTagListsRepository articleTagListsRepository;
|
||||
/*
|
||||
- Json 객체로 넘어온 태그들을 파싱해서 신규 태그인경우 저장
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user