一个简短的答案,因为您没有提供任何 @Entities :使用 @EmbeddedId
前任 :
@Embeddable
public class UserDescRegId {
private Long userId;
private Long userDescriptionId;
private Long userRegId;
//TODO add getters,setters, constructor, equals, hasCode...
}
@Entity
public class UserDescReg {
private UserDescRegId id = new UserDescRegId();
private Description description;
private Registration reg;
private User user;
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "user", column = @Column(name = "", nullable = false)),
@AttributeOverride(name = "description", column = @Column(name = "description", nullable = false)),
@AttributeOverride(name = "registration", column = @Column(name = "reg", nullable = false)) })
//TODO complete @AttributeOverrive
public UserDescRegId getId() {
return this.id;
}
//TODO getters/setters,
}