【发布时间】:2014-12-30 17:52:44
【问题描述】:
在休眠中是否类似于实体框架中的代码优先方法? 我正在尝试从 java 类(MySQL)准备数据库表。我已经准备好了带有 JPA 注释的 java 类,但我不确定现在该做什么(我正在使用 IntelliJ)。我应该在我的主目录中创建哪些表格?还是我应该使用一些工具?
我的一个类如下所示:
@Entity
public class Item {
@Id
@GeneratedValue
private long id;
@Column
private String text;
@ManyToMany(mappedBy = "items")
private Set<Container> containers = new HashSet<Container>();
public long getId() {
return id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Set<Container> getContainers() { return containers; }
}
【问题讨论】:
标签: java mysql hibernate jpa orm