package com.imcode.imcms.mapping.jpa.doc.content;

import com.imcode.imcms.mapping.jpa.doc.Version;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@MappedSuperclass
public abstract class VersionedContent {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "doc_id", unique = true, nullable = false, insertable = false, updatable = false)
    private Integer documentId;

    @NotNull
    @ManyToOne
    @JoinColumns({
            @JoinColumn(name = "doc_id", referencedColumnName = "doc_id"),
            @JoinColumn(name = "doc_version_no", referencedColumnName = "no")
    })
    private Version version;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Version getVersion() {
        return version;
    }

    public void setVersion(Version contentVersion) {
        this.version = contentVersion;
        this.documentId = contentVersion.getDocId();
        this.id = contentVersion.getId();
    }

    public Integer getDocumentId() {
        return documentId;
    }
}

@@ -1022,50 +1022,8 @@
 ();%0A
-        this.id = contentVersion.getId();%0A
     

Apply new UI to the admin panel and editors: - Versioned content no more stealing it's version's id.