발생한 예외
create table posts (
id bigint not null auto_increment,
created_at datetime(6),
modified_at datetime(6),
contents varchar(255),
like bigint,
title varchar(255) not null,
user_id bigint,
primary key (id)
) engine=InnoDB" via JDBC
[You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax
to use near 'like bigint, title varchar(255) not null, user_id bigint,' at line 6]
원래 코드
@Column
private long like = postLikeList == null ? 0 : postLikeList.size();
자꾸 posts Entity가 안 만들어지길래 왜 그런지 살펴봤더니 포스트 좋아요의 column을 like로 해놓았더니 like는 MySQL의 예약어라 사용할 수 없는 컬럼이라 발생하는 문제였다. like 변수명 자체를 postLike로 바꿔서 해결.
수정코드
@Column
private long postLike = postLikeList == null ? 0 : postLikeList.size();
'STUDY > SpringBoot' 카테고리의 다른 글
[TIL] 수업 자료 - 카카오 로그인 분석 (1) | 2023.08.02 |
---|---|
[TIL] SpringBoot dependency 버전 맞추기! (0) | 2023.07.25 |
[TIL] AnnotationException 예외 발생 (mappedBy) (0) | 2023.07.13 |
[TIL] DefaultHandlerException 예외발생(추가공부 필요) (0) | 2023.07.11 |
[TIL] http.authorizeHttpRequests.requestMatchers API 설정(정확한 해결 방법 추가 기록 필요) (0) | 2023.07.10 |