본문 바로가기 메뉴 바로가기

별별코딩

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

별별코딩

검색하기 폼
  • 분류 전체보기 (96)
    • 사소한 개발 일기 (3)
    • language (21)
      • java (17)
      • kotlin (4)
      • python (0)
    • backend (17)
      • spring boot (7)
      • jpa (4)
      • server (2)
      • linux (3)
      • 장애대응 (1)
    • database (5)
      • mysql (2)
      • redis (1)
      • mongodb (2)
    • devops (1)
      • docker (1)
    • etc (13)
      • git (8)
      • mac (1)
      • firebase (1)
      • etc (3)
    • error log (19)
    • computer science (2)
      • network (2)
    • algorithm (1)
    • project (9)
      • side project (3)
      • academy (6)
    • Series (5)
      • 자바 플레이그라운드 with TDD, 클린코드 (1)
      • 도메인 주도 개발 시작하기 (0)
      • 스프링 핵심 원리 - 기본편 (4)
  • 방명록

분류 전체보기 (96)
[mongodb] 데이터 insert하는 방법. 한개 insertOne(), 여러개 insertMany()

document 데이터 insert 하는 방법 { key : value } object 형태로 document 데이터를 insert 한다. insertOne() 으로 한개 데이터 넣기 db.diary.insertOne({ "content" : "재미있는 오늘!", "userId" : 11, "weather" : "sunny", "writtenAt" : "2023-02-18T00:00:00.000Z", "deleted" : false}); insertMany()로 여러개의 데이터 넣기 [ {}, {}, ...] 배열로 데이터를 넣는다. db.diary.insertMany([ { "content" : "hello world", "userId" : 22, "weather" : "cloudy", "written..

database/mongodb 2023. 3. 4. 14:23
kotlin - Jpa QueryDsl 다이나믹 쿼리로 where의 특정 조건 체크하기

kotlin 함수 ?.null { it } where 조건 안에서 특정 파라미터 값을 체크해 데이터 유무에 따라 사용할 수 있다. fun findByIdAndName(id: Long, name:String): List { return from(members) .where(members.id.eq(id), name?.let { members.name.eq(it) }) .fetch() } 코틀린에서 제공하는 함수를 queryDsl 쿼리문 안에서도 사용 가능하다. ?. : null 이 아닐 때 let { } : it 으로 자기 자신을 받아와서 객체의 상태를 변경할 수 있다. ?.let { null이 아닐 때 블럭을 실행한다. }

language/kotlin 2023. 3. 2. 22:11
JPA Batch Size : N+1문제 해결법

@BatchSize 연관된 엔티티를 조회할 때 지정한 size 만큼 where 조건의 in 절으로 조회한다. 1:N 관계의 Entity 정의 정의 조건 : 1명의 멤버는 여러 개의 주문을 가질 수 있다. Members (1) : Orders (N) * 부모 class : Members @Entity class Members( @Column(nullable = false, length = 50) var email: String, @Column(nullable = false, length = 20) var name: String, ) { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @OneToMany(mappedBy..

backend/jpa 2023. 2. 27. 11:31
[JPA] 두번 이상의 left join fetch가 필요할 때, MultipleBagFetchException 문제 해결

에러 메세지 org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [com.beside.backend.domain.entitiy.wisesaying.WiseSaying.emotionWiseSayingsWords, com.beside.backend.domain.entitiy.wisesaying.WiseSaying.wiseSayingBookmark]; nested exception is java.lang.IllegalArgumentException: org.hibernate.loader.Mult..

error log 2023. 2. 26. 18:43
"서버 접속이 안됩니다..." 서버 장애 대응기 (feat.Cannot Connect to Database Server)

사건의 발단 로그인 API가 안된다는 프론트엔드 팀원님의 갑작스런 메세지..... 보고 현기증나기 시작했다.ㅎ 왜냐면 함께 하던 백엔드 팀원님이 나가셔서 이제 내가 무조건 처리해야하기 때문에.. (처리 못하면 죽음뿐 ^^) 문제 상황 * Database server 접속 안됨 (MySQL Cannot Connect to Database Server) 디비 데이터 모두 초기화됨 * domain 접속 안됨 해결 방법 데이터베이스 도커 컨테이너 재기동 서버가 네이버 클라우드로 돌아가고 있는데 프로젝트 기간이 얼마 남지 않은 시점이라 처음에 크레딧 소멸을 의심했다. 다행히 아직 크레딧은 남아 있어서 클라우드에서 서버가 내려간건 아니었다. 그렇다면 디비 서버만 연결이 안된다는 건데, 여기서 클라우드 서버와 디비 ..

backend/장애대응 2023. 2. 26. 17:37
[Kotlin + JPA] Kotlin으로 작성한 JPA Query를 ChatGPT로 리팩토링 해보았다.

사용자의 구독 이력UserSubscribeHistory 을 확인하는 find 함수 기존 JPA Query 다음 코드는 사용자가 해당 채널을 구독하는지 조회하는 JPA Query이다. 사용자의 구독 이력 UserSubscribeHistory 에서 구독하는 채널명 channelName 인지 확인하고 UserSubscribeStatus 구독 상태 여부에 따라 UserSubscribeHistory를 반환한다. fun find(channelName: String, status: UserSubscribeStatus? = null): UserSubscribeHistory? { return queryFactory.select(userSubscribeHistory) .from(userSubscribeHistory) .w..

etc/etc 2023. 2. 20. 20:44
[MySQL] Error Code: 1175 safe update mode 해결방법

실행한 쿼리 delete from wise_saying_bookmark where wise_saying_id = 1 특정 행을 삭제하기 위해 쿼리문을 delete 쿼리문을 실행했다. 에러메세지 Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect. 원인 "safe update mode" 기능이 활성화되어 있을 때 발생한다. 데이터가 무작위로 수정되는 것을 방지하기 위한 기능으로, update / d..

error log 2023. 2. 20. 19:39
[MongoDB] Text index required for $text query (Full Text Search Index)

Full Text Search Index (전문 검색 인덱스) MongoDB에서 제공하는 Full Text Search (전문 검색) 기능을 사용하여 검색 기능을 구현하던 중 에러가 발생하였다. Text index required for $text query Full Text Search Index 를 생성하지 않아 발생하는 에러 Full Text Search Index 생성하기 Collection level db.컬렉션명.createIndex( { "$**": "text" } ) Field level db.컬렉션명.createIndex( { title: "text", contents: "text" } ) Full Text Search Index 삭제 index 의 이름으로 삭제한다. db.컬렉션명.dr..

database/mongodb 2023. 2. 19. 21:42
이전 1 ··· 3 4 5 6 7 8 9 ··· 12 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • bucket4j
  • 추상클래스
  • Git
  • checkout
  • Cannot construct instance of
  • redisson 분산락
  • Kotlin
  • junit5
  • 오블완
  • 스프링 스케줄링
  • 스프링오류
  • jvm warm-up 전략
  • FetchJoin
  • QueryDSL
  • addFilterBefore
  • Linux
  • array
  • JPA
  • Spring Security
  • n+1
  • ChatGPT
  • 배열
  • dto 클래스 생성자
  • spring boot 3
  • 자바 어플리케이션 실행 과정
  • port
  • MongoDB
  • Java
  • 티스토리챌린지
  • MultipleBagFetchException
more
«   2025/07   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바