我有两节课:
@Entity
@Table(name = "movies")
public class Movie implements Serializable {
@Id
private int movieID;
private String name;
private int year;
private Genre genre;
//constructor, getters, setters
}
@Entity
@Table(name = "genres")
public class Genreimplements Serializable {
@Id
private int genreID;
private String name;
//constructor, getters, setters
}
数据库表是(简化,因此您只看到字段):
电影(int movieID,文本名称,int year,intgenreID)
流派(intgenreID,文本名称)
如何将genreID 字段映射到Movie 类中的流派对象(最好使用注释)?
(我正在使用 jsf 和休眠)