/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ee.tlu.htk.dippler.entities; import java.io.Serializable; import java.util.Date; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.Lob; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.TableGenerator; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.xml.bind.annotation.XmlRootElement; /** * * @author metz */ @XmlRootElement @Entity @Table(name = "courseblog_comment") @NamedQueries({ @NamedQuery(name = "CourseblogComment.findAll", query = "SELECT c FROM CourseblogComment c"), @NamedQuery(name = "CourseblogComment.findById", query = "SELECT c FROM CourseblogComment c WHERE c.id = :id"), @NamedQuery(name = "CourseblogComment.findByTitle", query = "SELECT c FROM CourseblogComment c WHERE c.title = :title"), @NamedQuery(name = "CourseblogComment.findByCreated", query = "SELECT c FROM CourseblogComment c WHERE c.created = :created"), @NamedQuery(name = "CourseblogComment.findByModified", query = "SELECT c FROM CourseblogComment c WHERE c.modified = :modified"), @NamedQuery(name = "CourseblogComment.findByHidden", query = "SELECT c FROM CourseblogComment c WHERE c.hidden = :hidden"), @NamedQuery(name = "CourseblogComment.findByPostNotHidden", query = "SELECT c FROM CourseblogComment c WHERE c.courseblogPost = :post AND c.hidden = 0")}) public class CourseblogComment implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator = "CourseBlogPostCommentID") @TableGenerator(name="CourseBlogPostCommentID", table="id_gen", pkColumnName="ID_NAME", valueColumnName = "ID_VAL", pkColumnValue="LAST_COURSE_BLOGPOST_COMMENT", allocationSize=1) @Basic(optional = false) @Column(name = "id") private Long id; @Column(name = "title") private String title; @Lob @Column(name = "body", length = 2000) private String body; @Basic(optional = false) @Column(name = "created") @Temporal(TemporalType.TIMESTAMP) private Date created; @Basic(optional = false) @Column(name = "modified") @Temporal(TemporalType.TIMESTAMP) private Date modified; @Basic(optional = false) @Column(name = "hidden") private boolean hidden; @JoinColumn(name = "creator", referencedColumnName = "id") @ManyToOne(optional = false, fetch = FetchType.LAZY) private User user; @JoinColumn(name = "courseblog_post", referencedColumnName = "id") @ManyToOne(optional = false, fetch = FetchType.LAZY) private CourseblogPost courseblogPost; @JoinColumn(name = "course", referencedColumnName = "id") @ManyToOne(optional = false, fetch = FetchType.LAZY) private Course course; public CourseblogComment() { } public CourseblogComment(Long id) { this.id = id; } public CourseblogComment(Long id, Date created, Date modified, boolean hidden) { this.id = id; this.created = created; this.modified = modified; this.hidden = hidden; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; } public Date getModified() { return modified; } public void setModified(Date modified) { this.modified = modified; } public boolean getHidden() { return hidden; } public void setHidden(boolean hidden) { this.hidden = hidden; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public CourseblogPost getCourseblogPost() { return courseblogPost; } public void setCourseblogPost(CourseblogPost courseblogPost) { this.courseblogPost = courseblogPost; } public Course getCourse() { return course; } public void setCourse(Course course) { this.course = course; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof CourseblogComment)) { return false; } CourseblogComment other = (CourseblogComment) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "ee.tlu.htk.dippler.entities.CourseblogComment[id=" + id + "]"; } }