import org.hibernate.annotations.Type; @Entity public class Topic { private Category category ; private int id; private String msg; private String name; private String title; private User user ; @ManyToOne @JoinColumn(name="category_Id",referencedColumnName="id") public Category getCategory() { return category; } @Id @GeneratedValue public int getId() { return id; } @Lob @Type(type="text") public String getMsg() { return msg; } public String getName() { return name; } public String getTitle() { return title; } @ManyToOne //默认为eager 记住lazy @JoinColumn(name="user_Id",referencedColumnName="id") public User getUser() { return user; } public void setCategory(Category category) { this.category = category; } public void setId(int id) { this.id = id; } public void setMsg(String msg) { this.msg = msg; } public void setName(String name) { this.name = name; } public void setTitle(String title) { this.title = title; } public void setUser(User user) { this.user = user; }
code
最新推荐文章于 2020-09-12 00:23:45 发布