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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章