Spring boot 雙主鍵註解配置

表結構:

如圖,Spring boot 配置註解信息,

svconfiguration表:

@Entity(name = "SV_CONFIGURATION") @IdClass(SvConfigId.class)
public class SvConfiguration {

    @Id private String key;
    @Id private Integer version;

    private Float value;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Float getValue() {
        return value;
    }

    public void setValue(Float value) {
        this.value = value;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
}
svconfigurationVersion表:

@Entity(name = "SV_CONFIGURATION_VERSION")
public class SvConfigurationVersion {

    @Id
    private Integer version;
    private Date createtime;

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }
}

svconfigIdi表:

@IdClass(SvConfigId.class)
class SvConfigId implements Serializable {
    String key;
    Integer version;

}

這張表就是爲了svconfiguration雙主鍵使用的。
發佈了106 篇原創文章 · 獲贊 255 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章