항해99/미니프로젝트
@Lob(Large Object)
숲별
2022. 10. 27. 16:53
728x90
미니프로젝트를 진행하면서 이미지주소로 사진을 받아오기로 했는데
이미지 주소값이 상상이상으로 길어서 오류가 발생했다.
@Lob은 일반적인 데이터베이스에서 저장하는 길이인 255개 이상의 문자를 저장하고 싶을 때 지정한다.
Hibernate : @Lob (Large Object)
0. LOB은 가변길의를 갖는 큰 데이터를 저장하는데 사용하는 데이터형이다. 0-1 CLOB은 문자기반을 데이터를 저장하는데 사용된다. 0-2 BLOB은 binary 데이터를 저장하는데 사용된다. 1. @Lob은 일반적인
kogle.tistory.com
post entity에 image위에 @Lob어노테이션을 붙여서 해결
그리고 application.properties에
spring.jpa.properties.hibernate.format_sql= true
spring.jpa.properties.hibernate.show_sql= true
추가 해주면 실행시 sql문을 볼 수 있다.
create table post (
post_id bigint not null auto_increment,
category varchar(255) not null,
content varchar(255) not null,
image longtext not null,
title varchar(255) not null,
account_id bigint,
primary key (post_id)
) engine=InnoDB
image에 longtext가 붙어있다면 제대로 처리된 것.bb