只是您的代码不符合JPA。问题的原因是您将其
Member用作PK的一部分。 PK只能由以下Java类型的字段组成
这应该工作:
@Embeddablepublic class MemberAttributePk implements Serializable { @Column(name = "member_id") protected Long memberId; @Column(name = "name") protected String name; public MemberAttributePk() {} // get & set}@Entitypublic class MemberAttribute { @EmbeddedId protected MemberAttributePk memberAttributePk; @ManyToOne @JoinColumn(name="member_id") protected Member member; private String value; public MemberAttribute() {} // get & set}
还是一样
@ClassId
public class MemberAttributePk implements Serializable { protected Long memberId; protected String name; public MemberAttributePk() {} // get & set}@Entity@IdClass(MemberAttributePk.class)public class MemberAttribute { @Id @Column(name = "member_id") protected Long memberId; @Id @Column(name = "name") protected String name; @ManyToOne @JoinColumn(name="member_id") protected Member member; private String value; public MemberAttribute() {} // get & set}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)