package fr.plil.sio.examen.api; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import javax.persistence.Table; /** * A comment is made by an reporter (i.e. an owner) on ANY animal * (not only the ones he owns). * An reporter can have zero, one or more comments on any animal (i.e. it can * exists several comments from the same reporter on the same animal). * An animal can have zero, one or more comments by any reporter (i.e. it can * exists several comments from the same reporter on the same animal). * * TODO: complete the classes in API to support comment serialization in the * database. */ @Entity @Table(name="COMMENT_T") public class Comment { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @ManyToOne(optional = false) @JoinColumn(name="OWNER_ID") private Owner reporter; @ManyToOne(optional = false) @JoinColumn(name="ANIMAL_ID") private Animal animal; @Column(nullable = false) private String message; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Owner getReporter(){ return this.reporter; } public void setReporter(Owner owner){ this.reporter = owner; } public Animal getAnimal(){ return this.animal; } public void setAnimal(Animal animal){ this.animal = animal; } public String getMessage(){ return this.message; } public void setMessage(String message){ this.message = message; } }