package br.com.triadworks.issuetracker.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import org.conventionsframework.model.BaseEntity;
@Entity
public class Comentario implements Serializable,BaseEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_COMENTARIO")
@SequenceGenerator(name="SEQ_COMENTARIO", sequenceName="SEQ_COMENTARIO", allocationSize=1)
private Long id;
private String descricao;
@ManyToOne(fetch=FetchType.LAZY)
private Usuario autor;
private Date criadaEm;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Usuario getAutor() {
return autor;
}
public void setAutor(Usuario autor) {
this.autor = autor;
}
public Date getCriadaEm() {
return criadaEm;
}
public void setCriadaEm(Date criadaEm) {
this.criadaEm = criadaEm;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Comentario other = (Comentario) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@PrePersist
public void onSave() {
this.criadaEm = new Date();
}
}