package com.mycompany.myapp.domain; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.joda.deser.LocalDateDeserializer; import com.mycompany.myapp.domain.util.CustomLocalDateSerializer; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Type; import org.joda.time.LocalDate; import javax.persistence.*; import java.io.Serializable; import java.util.HashSet; import java.util.Set; /** * A Author. */ @Entity @Table(name = "T_AUTHOR") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Author implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(name = "name") private String name; @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate") @JsonDeserialize(using = LocalDateDeserializer.class) @JsonSerialize(using = CustomLocalDateSerializer.class) @Column(name = "birth_date", nullable = false) private LocalDate birthDate; @OneToMany(mappedBy = "author") @JsonIgnore @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) private Set<Book> books = new HashSet<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public LocalDate getBirthDate() { return birthDate; } public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; } public Set<Book> getBooks() { return books; } public void setBooks(Set<Book> books) { this.books = books; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Author author = (Author) o; if (id != null ? !id.equals(author.id) : author.id != null) return false; return true; } @Override public int hashCode() { return (int) (id ^ (id >>> 32)); } @Override public String toString() { return "Author{" + "id=" + id + ", name='" + name + "'" + ", birthDate='" + birthDate + "'" + '}'; } }