2
我有Spring MVC和Data JPA。我正在试图做我有的映射表。结构如下图所示:使用弹簧数据映射和提取组合键的实体JPA
Device
--------------
PK deviceId
deviceName
Setting
--------------
PK deviceId
PK packageName
PK name
value
而且我对这些表类:
@Entity
public class DeviceSetting implements Serializable {
@EmbeddedId
private String deviceId
private String deviceName;
@ManyToOne
@JoinColumn(name="deviceId", referencedColumnName="deviceId", insertable=false, updatable=false)
private Device device;
//Setters and Getters
}
@Embeddable
public class DeviceSettingPk implements Serializable {
private String deviceId;
private String packageName;
private String name;
public DeviceSettingPk(){}
public DeviceSettingPk(String deviceId, String packageName, String name) {
super();
this.deviceId = deviceId;
this.packageName = packageName;
this.name = name;
}
//Setters and Getters
}
@Entity
public class Device implements Serializable {
private static final long serialVersionUID = 1L;
@NotEmpty
@Id
@Column(name="deviceId")
private String deviceId;
private String deviceName;
//Getters and Setters
}
但当我把设备我没有得到设备的数据和设定数据具有相同的设备ID,并通过使用查询DeviceSetting repository.findOne(DEVICEID);
我还需要做什么来获取设备数据?任何意见将是有益的。谢谢。