N:1(다대일) 연관관계를 표현하는 어노테이션
@Entity
@Table(name = "board_posts")
@SequenceGenerator(
name = "post_pk_generator",
sequenceName = "board_posts_seq",
initialValue = 1000,
allocationSize = 1
)
@Getter
@Setter
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "post_pk_generator")
private Long id;
@Column(nullable = false)
private String title;
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;
@Column(nullable = false)
private String content;
private LocalDateTime createdDate;
private LocalDateTime updatedDate;
}