欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

JPA复合主键源码案例

程序员文章站 2022-04-04 09:17:44
...

http://note.youdao.com/share/?id=9065b839f2d6b3f1b6310ad9bb92d3f6type=note @Entity@Table(name = RELEASE_INFO_ELEMENT)public class ReleaseInfoElement { @EmbeddedId private PK pk = new PK(); @Column(name = VALUE) private String value; public

http://note.youdao.com/share/?id=9065b839f2d6b3f1b6310ad9bb92d3f6&type=note

@Entity @Table(name = "RELEASE_INFO_ELEMENT") public class ReleaseInfoElement { @EmbeddedId private PK pk = new PK(); @Column(name = "VALUE") private String value; public Long getInfoId() { return pk.infoId; } public void setInfoId(Long infoId) { pk.infoId = infoId; } public Long getParamId() { return pk.paramId; } @Override public String toString() { return "ReleaseInfoElement [infoId=" + pk.infoId + ", paramId=" + pk.paramId + ", value=" + value + "]"; } public void setParamId(Long paramId) { pk.paramId = paramId; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } @Embeddable public static class PK implements Serializable { @Column(name = "INFO_ID") private Long infoId; @Column(name = "PARAM_ID") private Long paramId; public PK() { super(); } } }