I would like to know how to create a Composite Combination through Hibernate annotation method. 

I have 3 tables Employee, Department &amp; Employee-Department-Juntion

Since I want to make Employee and Department as individual table, i created a Junction Table in order maintain the Many-to-Many relationship.

I would like to know how to Create Composite Primary Key for the Department Table
For the column Center_Code &amp; Depart_Code through Hibernate Annotations.

Could you please somebody help me how to solve this issue.

Below Here I also attached the Table Relation Ship and the Java POJO Class.

Table Relationship



JAVA POJO CLASS

package com.hibernate;

import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
 *
 * @author SPAR
 */
@Entity
public class Department {

    @Id
    private String cost_Center_Code;
    private String dep_Code;
    private String department;
    private String sub_Department;
    private String division;

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getDep_Code() {
        return dep_Code;
    }

    public void setDep_Code(String dep_Code) {
        this.dep_Code = dep_Code;
    }

    public String getCost_Center_Code() {
        return cost_Center_Code;
    }

    public void setCost_Center_Code(String cost_Center_Code) {
        this.cost_Center_Code = cost_Center_Code;
    }

    public String getDivision() {
        return division;
    }

    public void setDivision(String division) {
        this.division = division;
    }

    public String getSub_Department() {
        return sub_Department;
    }

    public void setSub_Department(String sub_Department) {
        this.sub_Department = sub_Department;
    }

    @Override
    public String toString() {
        return "Department{" + "cost_Center_Code=" + cost_Center_Code + ", dep_Code=" + dep_Code + ", department=" + department + ", sub_Department=" + sub_Department + ", division=" + division + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + Objects.hashCode(this.cost_Center_Code);
        hash = 79 * hash + Objects.hashCode(this.dep_Code);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Department other = (Department) obj;
        if (!Objects.equals(this.cost_Center_Code, other.cost_Center_Code)) {
            return false;
        }
        if (!Objects.equals(this.dep_Code, other.dep_Code)) {
            return false;
        }
        return true;
    }

}



Question: How to put @nickname at the comments?
Answer: @names autocomplete only when you actually need to use them.

If the auto-completion box doesn't appear after typing @ and the first character of a name, then the @name is not needed. Either you are addressing the OP, or trying to address someone that is not nameable in a comment.

See How do comment @replies work? for when naming someone with the @name syntax is needed. When you are talking directly with the OP on their question and noone else has as yet commented, for example, @name name completion is not available because you don't need to use that syntax to notify the author.

There is one exception to this; you can name an editor of your post in comment, but the name will not be available for auto-completion. E.g. if I were to edit your question, you can use @MartijnPieters in a comment and I would be notified, but you'd have to type out my name yourself.