超类属性和实体属性的组合键

时间:2018-06-21 18:08:58

标签: hibernate spring-boot jpa

我有一个应用实体,该实体具有引用作为主键。 我有ApplicationTypeCreation,它具有一个组合键,一个引用是从Application实体继承它,而NumCom是它自己的属性。 我想在由numCom和reference.com组成的applicationType Creation实体中创建一个组合键。那怎么办? 我使用Java作为编程语言,并使用Spring Boot和Hibernate作为框架。 这些是我的实体

    package biz.picosoft.entities;

    import java.util.Date;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;

    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;

    import org.hibernate.search.annotations.Indexed;

    @Entity
    @Indexed
    @Table(name = "ApplicationTypeCreation")
    public class ApplicationTypeCreation extends Application {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Column(name = "company")
        private String company;
        @Column(name = "clientType")
        private String clientType;
        @Column(name = "date")
        private Date date;
        @Column(name = "numConsultation")
        private String numConsultation;
        @Column(name = "numDC")
        private String numDC;
        @Column(name = "filterType")
        private String filterType;
        @Column(name = "isExternalBying")
        private Boolean isExternalBying;
        @Column(name = "isFabrication")
        private Boolean isFabrication;
        @Column(name = "fabricationDate")
        private Date fabricationDate;
        @Column(name = "isTransfert")
        private Boolean isTransfert;
        @Column(name = "isNewRef")
        private Boolean isNewRef;
        @Column(name = "isPieceOE")
        private Boolean isPieceOE;
        @Column(name = "isBrevete")
        private Boolean isBrevete;
        @Column(name = "packagingType")
        private String packagingType;
        @Column(name = "isNotice")
        private Boolean isNotice;
        @Column(name = "isClientFile")
        private Boolean isClientFile;
        @Column(name = "packagingDate")
        private Date packagingDate;
        @Column(name = "evaluationIndex")
        private String evaluationIndex;
        @Column(name = "comment" ,  columnDefinition="TEXT")
        private String comment;
        @Column(name = "marque"  )
        private String marque;
        @Column(name = "numCom"  )
        private String numCom;
        @OneToMany(cascade = CascadeType.ALL)
        @JoinTable(name = "App_oe", joinColumns = { @JoinColumn(name = "id") }, inverseJoinColumns = {
                @JoinColumn(name = "oeId") })
        private Set<OE> oeList = new HashSet<OE>(0);
        @OneToMany(cascade = CascadeType.ALL)
        @JoinTable(name = "App_provider", joinColumns = { @JoinColumn(name = "id") }, inverseJoinColumns = {
                @JoinColumn(name = "providerId") })
        private Set<Provider> providersList = new HashSet<Provider>(0);

        public ApplicationTypeCreation() {
            super();
        }

        public ApplicationTypeCreation(String reference, String company, String clientType,
                Date date, String numConsultation, String numDC, String filterType, Boolean isExternalBying,String marque,
                Boolean isFabrication, Date fabricationDate, Boolean isTransfert, Boolean isNewRef, Boolean isPieceOE,
                Boolean isBrevete, String packagingType, Boolean isNotice, Boolean isClientFile, Date packagingDate,
                String evaluationIndex,String numCom, String comment,Date creationDate, String status, Date deadLine, String appType ,String client,String codeClient,
                String demandeur, String refPiece,List<FileMetadata> listePiecesJointes) {
            super( reference,creationDate,  status,  deadLine,  appType,   client,  codeClient,
                      demandeur,   refPiece,null);

            this.numCom=numCom;
            this.company = company;
            this.clientType = clientType;
            this.date = date;
            this.numConsultation = numConsultation;
            this.numDC = numDC;
            this.filterType = filterType;
            this.isExternalBying = isExternalBying;
            this.isFabrication = isFabrication;
            this.fabricationDate = fabricationDate;
            this.isTransfert = isTransfert;
            this.isNewRef = isNewRef;
            this.isPieceOE = isPieceOE;
            this.isBrevete = isBrevete;
            this.packagingType = packagingType;
            this.isNotice = isNotice;
            this.isClientFile = isClientFile;
            this.packagingDate = packagingDate;
            this.evaluationIndex = evaluationIndex;
            this.comment = comment;
            this.marque=marque;
        }






        public String getCompany() {
            return company;
        }

        public void setCompany(String company) {
            this.company = company;
        }


        public String getClientType() {
            return clientType;
        }

        public void setClientType(String clientType) {
            this.clientType = clientType;
        }

        public Date getDate() {
            return date;
        }

        public void setDate(Date date) {
            this.date = date;
        }

        public String getNumConsultation() {
            return numConsultation;
        }

        public void setNumConsultation(String numConsultation) {
            this.numConsultation = numConsultation;
        }

        public String getNumDC() {
            return numDC;
        }

        public void setNumDC(String numDC) {
            this.numDC = numDC;
        }

        public String getFilterType() {
            return filterType;
        }

        public void setFilterType(String filterType) {
            this.filterType = filterType;
        }

        public Boolean getIsExternalBying() {
            return isExternalBying;
        }

        public void setIsExternalBying(Boolean isExternalBying) {
            this.isExternalBying = isExternalBying;
        }

        public Boolean getIsFabrication() {
            return isFabrication;
        }

        public void setIsFabrication(Boolean isFabrication) {
            this.isFabrication = isFabrication;
        }

        public Date getFabricationDate() {
            return fabricationDate;
        }

        public void setFabricationDate(Date fabricationDate) {
            this.fabricationDate = fabricationDate;
        }

        public Boolean getIsTransfert() {
            return isTransfert;
        }

        public void setIsTransfert(Boolean isTransfert) {
            this.isTransfert = isTransfert;
        }

        public Boolean getIsNewRef() {
            return isNewRef;
        }

        public void setIsNewRef(Boolean isNewRef) {
            this.isNewRef = isNewRef;
        }

        public Boolean getIsPieceOE() {
            return isPieceOE;
        }

        public void setIsPieceOE(Boolean isPieceOE) {
            this.isPieceOE = isPieceOE;
        }

        public Boolean getIsBrevete() {
            return isBrevete;
        }

        public void setIsBrevete(Boolean isBrevete) {
            this.isBrevete = isBrevete;
        }

        public String getPackagingType() {
            return packagingType;
        }

        public void setPackagingType(String packagingType) {
            this.packagingType = packagingType;
        }

        public Boolean getIsNotice() {
            return isNotice;
        }

        public void setIsNotice(Boolean isNotice) {
            this.isNotice = isNotice;
        }

        public Boolean getIsClientFile() {
            return isClientFile;
        }

        public void setIsClientFile(Boolean isClientFile) {
            this.isClientFile = isClientFile;
        }

        public Date getPackagingDate() {
            return packagingDate;
        }

        public void setPackagingDate(Date packagingDate) {
            this.packagingDate = packagingDate;
        }

        public String getEvaluationIndex() {
            return evaluationIndex;
        }

        public void setEvaluationIndex(String evaluationIndex) {
            this.evaluationIndex = evaluationIndex;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        public Set<OE> getOeList() {
            return oeList;
        }

        public void setOeList(Set<OE> oeList) {
            this.oeList = oeList;
        }

        public String getMarque() {
            return marque;
        }

        public void setMarque(String marque) {
            this.marque = marque;
        }

        public String getNumCom() {
            return numCom;
        }

        public void setNumCom(String numCom) {
            this.numCom = numCom;
        }






    }

我的超类

package biz.picosoft.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.TokenizerDef;

@Entity
@Indexed
@Inheritance
@Table(name = "application", uniqueConstraints = { @UniqueConstraint(columnNames = "reference") })
@AnalyzerDef(name = "customAnalyser", tokenizer = @TokenizerDef(factory = WhitespaceTokenizerFactory.class), filters = {

        @TokenFilterDef(factory = LowerCaseFilterFactory.class), // Lowercase
                                                                    // all
                                                                    // characters

})
public class Application implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

    @Column(name = "reference")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String reference;

    @Column(name = "creationDate")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private Date creationDate;

    @Column(name = "status")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String status;
    @Column(name = "deadLine")
    private Date deadLine;
    @Column(name = "appType")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String appType;
    @Column(name = "client")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String client;
    @Column(name = "codeClient")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String codeClient;
    @Column(name = "demandeur")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String demandeur;
    @Column(name = "refPiece")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String refPiece;
    @Column(name = "projectId")
    @Analyzer(definition = "customAnalyser")
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private Long projectId;
    @Column(name = "critereRefus")
    private String critereRefus;
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "App_files", joinColumns = { @JoinColumn(name = "idApp") }, inverseJoinColumns = {
            @JoinColumn(name = "idFile") })
    private List<FileMetadata> listePiecesJointes = new ArrayList<FileMetadata>();

    public Long getId() {
        return id;
    }

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

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getDeadLine() {
        return deadLine;
    }

    public void setDeadLine(Date deadLine) {
        this.deadLine = deadLine;
    }

    public String getAppType() {
        return appType;
    }

    public void setAppType(String appType) {
        this.appType = appType;
    }

    public Application() {
        super();
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public String getDemandeur() {
        return demandeur;
    }

    public void setDemandeur(String demandeur) {
        this.demandeur = demandeur;
    }

    public String getRefPiece() {
        return refPiece;
    }

    public void setRefPiece(String refPiece) {
        this.refPiece = refPiece;
    }

    public String getCritereRefus() {
        return critereRefus;
    }

    public void setCritereRefus(String critereRefus) {
        this.critereRefus = critereRefus;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public List<FileMetadata> getListePiecesJointes() {
        return listePiecesJointes;
    }

    public void setListePiecesJointes(List<FileMetadata> listePiecesJointes) {
        this.listePiecesJointes = listePiecesJointes;
    }

    public String getCodeClient() {
        return codeClient;
    }

    public void setCodeClient(String codeClient) {
        this.codeClient = codeClient;
    }

    public Application(String reference, Date creationDate, String status, Date deadLine, String appType, String client,
            String codeClient, String demandeur, String refPiece, Long projectId) {
        super();
        this.reference = reference;
        this.creationDate = creationDate;
        this.status = status;
        this.deadLine = deadLine;
        this.codeClient = codeClient;
        this.appType = appType;
        this.client = client;
        this.demandeur = demandeur;
        this.refPiece = refPiece;
        this.projectId = projectId;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((appType == null) ? 0 : appType.hashCode());
        result = prime * result + ((client == null) ? 0 : client.hashCode());
        result = prime * result + ((codeClient == null) ? 0 : codeClient.hashCode());
        result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
        result = prime * result + ((critereRefus == null) ? 0 : critereRefus.hashCode());
        result = prime * result + ((deadLine == null) ? 0 : deadLine.hashCode());
        result = prime * result + ((demandeur == null) ? 0 : demandeur.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((listePiecesJointes == null) ? 0 : listePiecesJointes.hashCode());
        result = prime * result + ((projectId == null) ? 0 : projectId.hashCode());
        result = prime * result + ((refPiece == null) ? 0 : refPiece.hashCode());
        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
        result = prime * result + ((status == null) ? 0 : status.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Application other = (Application) obj;
        if (appType == null) {
            if (other.appType != null)
                return false;
        } else if (!appType.equals(other.appType))
            return false;
        if (client == null) {
            if (other.client != null)
                return false;
        } else if (!client.equals(other.client))
            return false;
        if (codeClient == null) {
            if (other.codeClient != null)
                return false;
        } else if (!codeClient.equals(other.codeClient))
            return false;
        if (creationDate == null) {
            if (other.creationDate != null)
                return false;
        } else if (!creationDate.equals(other.creationDate))
            return false;
        if (critereRefus == null) {
            if (other.critereRefus != null)
                return false;
        } else if (!critereRefus.equals(other.critereRefus))
            return false;
        if (deadLine == null) {
            if (other.deadLine != null)
                return false;
        } else if (!deadLine.equals(other.deadLine))
            return false;
        if (demandeur == null) {
            if (other.demandeur != null)
                return false;
        } else if (!demandeur.equals(other.demandeur))
            return false;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        if (listePiecesJointes == null) {
            if (other.listePiecesJointes != null)
                return false;
        } else if (!listePiecesJointes.equals(other.listePiecesJointes))
            return false;
        if (projectId == null) {
            if (other.projectId != null)
                return false;
        } else if (!projectId.equals(other.projectId))
            return false;
        if (refPiece == null) {
            if (other.refPiece != null)
                return false;
        } else if (!refPiece.equals(other.refPiece))
            return false;
        if (reference == null) {
            if (other.reference != null)
                return false;
        } else if (!reference.equals(other.reference))
            return false;
        if (status == null) {
            if (other.status != null)
                return false;
        } else if (!status.equals(other.status))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Application [id=" + id + ", reference=" + reference + ", creationDate=" + creationDate + ", status="
                + status + ", deadLine=" + deadLine + ", appType=" + appType + ", client=" + client + ", codeClient="
                + codeClient + ", demandeur=" + demandeur + ", refPiece=" + refPiece + ", projectId=" + projectId
                + ", critereRefus=" + critereRefus + ", listePiecesJointes=" + listePiecesJointes + "]";
    }

}

0 个答案:

没有答案