假设我们有一个名为LatLng
的类:
public class LatLng {
private long id;
private double latitude;
private double longitude;
//setters & getters
}
如下图所示:
我们在PoliceStation
和LatLng
以及Hotel
和LatLng
依旧......
我们如何在休眠中创建这样的关系? (注释和xml映射)
答案 0 :(得分:0)
您需要的是实体之间的双向一对一关联。
检查以下链接:
Hibernate - bidirectional @OneToOne
Hibernate bidirectional using mapping files.
按照链接尝试创建您的实体。