1 回答
TA贡献1744条经验 获得超4个赞
试试这个:
@Table(name = "training")
public class Training {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "training_id")
private int id;
@Column(name = "training_name")
private String trainingName;
@Column(name = "date")
private Date date;
@OneToMany(mappedBy = "training")
private Set<Exercise> exercises = new HashSet<>();
@Entity
@Table(name = "exercise")
public class Exercise {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "exercise_id")
private int id;
@Column(name = "exercise_name")
private String name;
@Column(name = "weight")
private double weight;
@Column(name = "series")
private int series;
@Column(name = "training_id")
private int trainingId;
@ManyToOne
@JsonIgnoreProperties("exercises")
private Training training;
这将是外键引用的 2 个单独的数据库。
编辑:这将是外键引用的2 个单独的表(不是数据库)。
添加回答
举报