package org.jhipster.domain; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence.*; import javax.validation.constraints.*; import java.io.Serializable; import java.time.ZonedDateTime; import java.util.HashSet; import java.util.Set; import java.util.Objects; /** * A Entry. */ @Entity @Table(name = "entry") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Entry implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") @SequenceGenerator(name = "sequenceGenerator") private Long id; @NotNull @Column(name = "title", nullable = false) private String title; @NotNull @Lob @Column(name = "content", nullable = false) private String content; @NotNull @Column(name = "date", nullable = false) private ZonedDateTime date; @ManyToOne private Blog blog; @ManyToMany @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @JoinTable(name = "entry_tag", joinColumns = @JoinColumn(name="entries_id", referencedColumnName="id"), inverseJoinColumns = @JoinColumn(name="tags_id", referencedColumnName="id")) private Set<Tag> tags = new HashSet<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getTitle() { return title; } public Entry title(String title) { this.title = title; return this; } public void setTitle(String title) { this.title = title; } public String getContent() { return content; } public Entry content(String content) { this.content = content; return this; } public void setContent(String content) { this.content = content; } public ZonedDateTime getDate() { return date; } public Entry date(ZonedDateTime date) { this.date = date; return this; } public void setDate(ZonedDateTime date) { this.date = date; } public Blog getBlog() { return blog; } public Entry blog(Blog blog) { this.blog = blog; return this; } public void setBlog(Blog blog) { this.blog = blog; } public Set<Tag> getTags() { return tags; } public Entry tags(Set<Tag> tags) { this.tags = tags; return this; } public Entry addTag(Tag tag) { this.tags.add(tag); tag.getEntries().add(this); return this; } public Entry removeTag(Tag tag) { this.tags.remove(tag); tag.getEntries().remove(this); return this; } public void setTags(Set<Tag> tags) { this.tags = tags; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Entry entry = (Entry) o; if (entry.id == null || id == null) { return false; } return Objects.equals(id, entry.id); } @Override public int hashCode() { return Objects.hashCode(id); } @Override public String toString() { return "Entry{" + "id=" + id + ", title='" + title + "'" + ", content='" + content + "'" + ", date='" + date + "'" + '}'; } }