Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package hr.softwarecity.osijek.model; import com.fasterxml.jackson.annotation.JsonIgnore; import java.io.Serializable; import java.util.Objects; import javax.persistence.Embeddable; import javax.persistence.ManyToOne; /** * * @author Leon */ @Embeddable public class CompositeKey implements Serializable { @ManyToOne @JsonIgnore public Person person; @ManyToOne private Pollination pollination; public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } public Pollination getPollination() { return pollination; } public void setPollination(Pollination pollination) { this.pollination = pollination; } @Override public int hashCode() { int hash = 5; hash = 19 * hash + Objects.hashCode(this.person); hash = 19 * hash + Objects.hashCode(this.pollination); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final CompositeKey other = (CompositeKey) obj; if (!Objects.equals(this.person, other.person)) { return false; } if (!Objects.equals(this.pollination, other.pollination)) { return false; } return true; } }