我在说明spring boot服务器时遇到异常。我想要内连的第二个表(XYZ)有两个键(AGENTID,TERMID),AGENTID是两个表中的主键。
@Entity
@Table(name="abc")
public class Agent {
@Id
@Column(name="AGENTID")
private int agentId;
@Column(name="AGENTNAME")
private String agentName;
@OneToOne(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@JoinColumn(name = "AGENTID", unique = false, nullable = true, insertable = true, updatable = true)
private Terminal terminal;
}
@Entity
@Table(name="xyz")
public class Terminal {
@EmbeddedId
private TerminalIds terminalIds;
}
public class TerminalIds implements Serializable{
private static final long serialVersionUID = 3811257594320593004L;
@Column(name="AGENTID")
private int agentId;
@Column(name="TERMID")
private String terminalId;
}