JPA 多主键联合查询
public class PartyPK implements Serializable{ private String partyId; @Column(name = "account_type_id") private String accountTypeId; public String getPartyId() { return partyId; } public void setPartyId(String partyId) { this.partyId = partyId; } public String getAccountTypeId() { return accountTypeId; } public void setAccountTypeId(String accountTypeId) { this.accountTypeId = accountTypeId; } }
@Entity @IdClass(value = PartyPK.class) @Table(name = "account") public class Account extends Model{ @Id private String partyId; @Id private String accountTypeId; @ ToOne @JoinColumn(name = "account_type_id",insertable = false,updatable = false) private AccountType accountType; private String account; private String password; private String passwordSalt; private String headImage; public Account(){} //省略getter setter }