CompoEntryFile.java 4.74 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fi.insomnia.bortal.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
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.Temporal;
import javax.persistence.TemporalType;

/**
 * 
 * @author jkj
 */
@Entity
@Table(name = "entry_files")
@NamedQueries( {
	@NamedQuery(name = "CompoEntryFile.findAll", query = "SELECT c FROM CompoEntryFile c"),
	@NamedQuery(name = "CompoEntryFile.findByEntryFilesId", query = "SELECT c FROM CompoEntryFile c WHERE c.entryFilesId = :entryFilesId"),
	@NamedQuery(name = "CompoEntryFile.findByMimeType", query = "SELECT c FROM CompoEntryFile c WHERE c.mimeType = :mimeType"),
	@NamedQuery(name = "CompoEntryFile.findByFileName", query = "SELECT c FROM CompoEntryFile c WHERE c.fileName = :fileName"),
	@NamedQuery(name = "CompoEntryFile.findByDescription", query = "SELECT c FROM CompoEntryFile c WHERE c.description = :description"),
	@NamedQuery(name = "CompoEntryFile.findByHash", query = "SELECT c FROM CompoEntryFile c WHERE c.hash = :hash"),
	@NamedQuery(name = "CompoEntryFile.findByComment", query = "SELECT c FROM CompoEntryFile c WHERE c.comment = :comment"),
	@NamedQuery(name = "CompoEntryFile.findByUploaded", query = "SELECT c FROM CompoEntryFile c WHERE c.uploaded = :uploaded") })
public class CompoEntryFile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "entry_files_id", nullable = false)
    private Integer entryFilesId;
    @Column(name = "mime_type", length = 2147483647)
    private String mimeType;
    @Column(name = "file_name", length = 2147483647)
    private String fileName;
    @Column(name = "description", length = 2147483647)
    private String description;
    @Column(name = "hash", length = 2147483647)
    private String hash;
    @Column(name = "comment", length = 2147483647)
    private String comment;
    @Lob
    @Column(name = "file_data")
    private byte[] fileData;
    @Column(name = "uploaded", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date uploaded;
    @JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false)
    @ManyToOne(optional = false)
    private CompoEntry entriesId;

    public CompoEntryFile() {
    }

    public CompoEntryFile(Integer entryFilesId) {
	this.entryFilesId = entryFilesId;
    }

    public CompoEntryFile(Integer entryFilesId, Date uploaded) {
	this.entryFilesId = entryFilesId;
	this.uploaded = uploaded;
    }

    public Integer getEntryFilesId() {
	return entryFilesId;
    }

    public void setEntryFilesId(Integer entryFilesId) {
	this.entryFilesId = entryFilesId;
    }

    public String getMimeType() {
	return mimeType;
    }

    public void setMimeType(String mimeType) {
	this.mimeType = mimeType;
    }

    public String getFileName() {
	return fileName;
    }

    public void setFileName(String fileName) {
	this.fileName = fileName;
    }

    public String getDescription() {
	return description;
    }

    public void setDescription(String description) {
	this.description = description;
    }

    public String getHash() {
	return hash;
    }

    public void setHash(String hash) {
	this.hash = hash;
    }

    public String getComment() {
	return comment;
    }

    public void setComment(String comment) {
	this.comment = comment;
    }

    public byte[] getFileData() {
	return fileData;
    }

    public void setFileData(byte[] fileData) {
	this.fileData = fileData;
    }

    public Date getUploaded() {
	return uploaded;
    }

    public void setUploaded(Date uploaded) {
	this.uploaded = uploaded;
    }

    public CompoEntry getEntriesId() {
	return entriesId;
    }

    public void setEntriesId(CompoEntry entriesId) {
	this.entriesId = entriesId;
    }

    @Override
    public int hashCode() {
	int hash = 0;
	hash += (entryFilesId != null ? entryFilesId.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 CompoEntryFile)) {
	    return false;
	}
	CompoEntryFile other = (CompoEntryFile) object;
	if ((this.entryFilesId == null && other.entryFilesId != null)
		|| (this.entryFilesId != null && !this.entryFilesId
			.equals(other.entryFilesId))) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "fi.insomnia.bortal.model.CompoEntryFile[entryFilesId="
		+ entryFilesId + "]";
    }

}