본문 바로가기

JpaRepository3

JpaRepository join using QueryProjection with DTO(kotlin) JpaRepository의 join을 사용하는 방법은 여러가지가 있습니다. 그 중 저는 QueryProjection을 이용한 방법을 사용했습니다. 코틀린 data class에서 QueryProjection을 사용하기 위해서는 아래와 같이 선언해주시면 됩니다. data class MovieListDTO @QueryProjection constructor( val MovieId: String = "", ... ) MovieInfoController @RestController @RequestMapping("/api/movieinfo") class MovieInfoController( val movieInfoService: MovieInfoServiceimpl, val movieCreatorService: M.. 2023. 3. 13.
JpaRepository saveAll(Insert) 사용하기 TheaterData(movieTheater=MB, city= 인, brchKR=검단, brchEN=Geomdan, addrKR= 인천광역시 서구 서곶로 788 (당하동) 홀리랜드 4층 메가박스 검단, addrEN=788, Seogot-ro, Seo-gu, Incheon, Republic of Korea, theaterCode=4041) TheaterData를 구하던 중 city가 제대로 안들어가 확인해 보니 주소에 띄어쓰기가 들어가 있는 친구가 있습니다. 주소들은 전부 trim을 적용해 줬습니다. addrEN의 경우 메가박스만 존재합니다. 나머지 영화관은 영어 주소를 제공하지 않습니다. CGV의 경우 CINE de CHEF 가 붙은 동일한 영화관이 존재합니다. 압구정의 경우 CINE de CHEF 압구.. 2023. 3. 12.
JpaRepository SQLInsert ID column 순서 바뀜 주의... MovieTheater의 경우 "CGV, MB, LC"로 지정 해줘서 넣어 주기 때문에 null이 절대 들어 가지 않습니다... 하도 이상해서 varchar대신 text로 변경하여 값을 확인해 보니 주소 값이 앞에 있습니다...? 현재 Entity 코드입니다. package com.threemovie.threemovieapi.Entity import com.threemovie.threemovieapi.Entity.PK.TheaterDataPK import jakarta.persistence.* import org.hibernate.annotations.SQLInsert @Entity @Table(name = "TheaterData") @IdClass(TheaterDataPK::class) @SQLInse.. 2023. 3. 12.