Board ( 연관 관계 mappedBy 수정 )
페이지 정보
작성자 관리자 작성일 24-06-27 12:10 조회 69 댓글 0본문
package web.domain;
import java.util.HashSet;
import java.util.Set;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.*;
@Entity
@Data
@ToString(exclude = "imageSet")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name= "board")
public class Board extends BaseEntity {
@Id // primary key
@GeneratedValue(strategy = GenerationType.IDENTITY) // auto_increment
private Long bno;
@Column(length = 255, nullable = false) //칼럼의 저장 길이, null 허용 여부
private String title;
@Column(columnDefinition = "TEXT", nullable = false)
private String content;
@Column(length = 20, nullable = false)
private String writer;
//제목, 내용만 수정
public void change(String title, String content) {
this.title = title;
this.content = content;
}
@OneToMany(mappedBy = "board") //BoardImage의 board변수
@Builder.Default
private Set<BoardImage> imageSet = new HashSet();
}
댓글목록 0
등록된 댓글이 없습니다.