package com.spring.crudprac.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
@Setter
@Getter // get 함수를 일괄적으로 만들어줍니다.
@NoArgsConstructor // 기본 생성자를 만들어줍니다.
@Entity // DB 테이블 역할을 합니다.
public class Posting {
// ID가 자동으로 생성 및 증가합니다.
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
private Long id;
// nullable: null 허용 여부
// unique: 중복 허용 여부 (false 일때 중복 허용)
@Column(nullable = false)
private String username;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String description;
public Posting(PostDto postDto) {
this.username = postDto.getUsername();
this.password = postDto.getPassword();
this.title = postDto.getTitle();
this.description = postDto.getDescription();
}
}
최초 설계했던 DB 테이블을 바탕으로
Entity를 작성했다.