我有那两门课
@Data
@Entity
@Table(name="arrow")
public class Arrow {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false, updatable = false)
private Integer id;
@Column(name = "id_source")
private Integer idSource;
@Column(name = "id_destination")
private Integer idDestination;
@Column(name = "capacity")
private Integer capacity;
@OneToMany(mappedBy="id")
private List<Edge> edges;
}
和
@Data
@Entity
@Table(name="edge")
public class Edge {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false, updatable = false)
private Long id;
@Column(name = "latitude")
private Double latitude;
@Column(name = "longitude")
private Double longitude;
@ManyToOne
@JoinColumn(name="id_source", nullable=false)
private Arrow idSource;
@ManyToOne
@JoinColumn(name="id_destination", nullable=false)
private Arrow idDestination;
}
我希望idsource从边缘Map到id,也希望idDestination从边缘Map到id。。。
我试着把他们联系起来,但我不知道怎么。。。它们之间的正确关系是什么?或者我应该改变表的逻辑吗?
谢谢!
2条答案
按热度按时间mcvgt66p1#
你应该吃点
和
p、 在实体中使用@data有点异味,可能会引起问题
voj3qocg2#
用这样的方法: