package com.mycompany.myapp.domain; import com.fasterxml.jackson.annotation.JsonIgnore; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence.*; import javax.validation.constraints.*; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import java.util.Objects; /** * A Label. */ @Entity @Table(name = "label") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Label implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @NotNull @Size(min = 3) @Column(name = "label", nullable = false) private String label; @ManyToMany(mappedBy = "labels") @JsonIgnore @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) private Set<Operation> operations = new HashSet<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public Set<Operation> getOperations() { return operations; } public void setOperations(Set<Operation> operations) { this.operations = operations; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Label label = (Label) o; if ( ! Objects.equals(id, label.id)) return false; return true; } @Override public int hashCode() { return Objects.hashCode(id); } @Override public String toString() { return "Label{" + "id=" + id + ", label='" + label + "'" + '}'; } }