본문 바로가기
Spring/JPA

Entity-Table 매핑 - 필드 매핑(@Lob)

by YellowCow 2023. 2. 23.

@Lob은 대용량 데이터를 저장할 때 사용한다

 

오라클의 경우 BLOB, CLOB

MySQL의 경우 BLOB, TEXT와 매핑된다

 

@Lob은 Java의 데이터 타입에 따라 매핑되는 타입이 달라진다

 

오라클을 예시로 들자면 아래와 같이 매핑될 수 있다

  • BLOB: byte[], java.sql.BLOB
  • CLOB: String, char[], java.sql.CLOB

 

아래는 사용 예이다

@Entity
public class Report{
    @Id
    private Long Id;

    private String title;
    
    //CLOB
    @Lob
    private String reportContent
    
    //BLOB
    @Lob
    private byte[] attachedFile;
}

댓글