/* * 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.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.persistence.Transient; import javax.xml.bind.annotation.XmlRootElement; /** * * @author metz */ @XmlRootElement @Entity @Table(name = "image") @NamedQueries({ @NamedQuery(name = "Image.findAll", query = "SELECT i FROM Image i"), @NamedQuery(name = "Image.findById", query = "SELECT i FROM Image i WHERE i.id = :id"), @NamedQuery(name = "Image.findByName", query = "SELECT i FROM Image i WHERE i.name = :name"), @NamedQuery(name = "Image.findByFiletype", query = "SELECT i FROM Image i WHERE i.filetype = :filetype"), @NamedQuery(name = "Image.findByFilesize", query = "SELECT i FROM Image i WHERE i.filesize = :filesize"), @NamedQuery(name = "Image.findByCreated", query = "SELECT i FROM Image i WHERE i.created = :created"), @NamedQuery(name = "Image.findByModified", query = "SELECT i FROM Image i WHERE i.modified = :modified"), @NamedQuery(name = "Image.findByTrashed", query = "SELECT i FROM Image i WHERE i.trashed = :trashed")}) public class Image implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator = "ImageID") @TableGenerator(name="ImageID", table="id_gen", pkColumnName="ID_NAME", valueColumnName = "ID_VAL", pkColumnValue="LAST_IMAGE", allocationSize=1) @Basic(optional = false) @Column(name = "id") private Long id; @Lob @Column(name = "image") private byte[] image; @Basic(optional = false) @Column(name = "name") private String name; @Column(name = "filetype") private String filetype; @Column(name = "filesize") private Integer filesize; @Basic(optional = false) @Column(name = "created") @Temporal(TemporalType.TIMESTAMP) private Date created; @Basic(optional = false) @Column(name = "modified") @Temporal(TemporalType.TIMESTAMP) private Date modified; @Column(name = "trashed") private Boolean trashed; @JoinColumn(name = "creator", referencedColumnName = "id") @ManyToOne private User creator; @Transient private Boolean delete; public Image() { } public Image(Long id) { this.id = id; } public Image(Long id, String name, Date created, Date modified, User creator) { this.id = id; this.name = name; this.created = created; this.modified = modified; this.creator = creator; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public User getCreator() { return creator; } public void setCreator(User user) { this.creator = user; } public byte[] getImage() { return image; } public void setImage(byte[] image) { this.image = image; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getFiletype() { return filetype; } public void setFiletype(String filetype) { this.filetype = filetype; } public Integer getFilesize() { return filesize; } public void setFilesize(Integer filesize) { this.filesize = filesize; } 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 getTrashed() { return trashed; } public void setTrashed(Boolean trashed) { this.trashed = trashed; } public Boolean getDelete() { return delete; } public void setDelete(Boolean delete) { this.delete = delete; } @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 Image)) { return false; } Image other = (Image) 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.Image[id=" + id + "]"; } }