-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#386 [feat] 필명, 글모임명 중복체크 중 띄어쓰기 관련 로직 구현 #388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿 고생하셨습니다 :)
코멘트 확인해주세요!
|
||
boolean existsWriterNameByMoimAndName(final Moim moim, final String name); | ||
@Query("SELECT CASE WHEN COUNT(w) > 0 THEN TRUE ELSE FALSE END FROM WriterName w WHERE w.moim = :moim AND w.normalizedName = :normalizedName") | ||
boolean existsWriterNameByMoimAndName(@Param("moim") Moim moim, @Param("normalizedName") String normalizedName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2
파라미터에 final 키워드 추가해주세요!
@@ -18,8 +20,8 @@ public interface WriterNameRepository extends JpaRepository<WriterName, Long> { | |||
|
|||
List<WriterName> findByMoimId(final Long moimId); | |||
|
|||
|
|||
boolean existsWriterNameByMoimAndName(final Moim moim, final String name); | |||
@Query("SELECT CASE WHEN COUNT(w) > 0 THEN TRUE ELSE FALSE END FROM WriterName w WHERE w.moim = :moim AND w.normalizedName = :normalizedName") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3
기존 쿼리를 사용하지 않은 대신 JPQL을 사용한 이유가 있으신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿 :) 머지해주세요!
✒️ 관련 이슈번호
Key Changes 🔑
글모임과 필명 모두 "normalizedName"로 띄어쓰기를 제거하고, 대소문자를 소문자로 변경한 필드를 두었습니다.
글모임명, 필명 생성 과정에서 normalizedName 값을 저장하도록 하였고,
(현재 수정 로직이 있는 경우에 대해서는) normalizedName 값도 수정되도록 하였습니다.
현재 로직에서는 이렇게 normalizedName이 name과 함께 생성 및 변동될 수 있도록 하였지만
데이터 무결성을 확실히 지킬 수 있는 방법을 찾아보았고 prepersist, preupdate 어노테이션을 적용해보았습니다.
엔티티가 db에 저장되기 전, 그리고 엔티티의 상태가 변경되어 데이터베이스에 업데이트되기 전에 호출되는 어노테이션입니다.