Files
tp-hibernate-project/hibernate-project/src/main/java/com/humanbooster/model/Article.java

62 lines
1.1 KiB
Java

package com.humanbooster.model;
import jakarta.persistence.*;
@Entity
public class Article {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "title", nullable = false, length = 100)
private String title;
@Column(name = "content", nullable = false)
private String content;
@ManyToOne
@JoinColumn(name="author_id", nullable=false)
private User author;
public Article() {}
public Article (String title, String content, User author){
this.title = title;
this.content = content;
this.author = author;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public User getAuthor() {
return author;
}
public void setAuthor(User author) {
this.author = author;
}
}