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

package fi.insomnia.bortal.model;


import java.util.Date;

import javax.persistence.Basic;
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;
import javax.persistence.Version;

/**
 *
 * @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 ModelInterface {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "entry_files_id", nullable = false)
    private Integer id;
    @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;
    @Basic(optional = false)
    @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 entry;

    @Version
    @Column(nullable = false)
    private int jpaVersionField;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public CompoEntryFile() {
    }

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

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

    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 entry;
    }

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

    @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 CompoEntryFile)) {
            return false;
        }
        CompoEntryFile other = (CompoEntryFile) 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 "fi.insomnia.bortal.model.CompoEntryFile[entryFilesId=" + id + "]";
    }

    public void setJpaVersionField(int jpaVersionField) {
	this.jpaVersionField = jpaVersionField;
    }

    public int getJpaVersionField() {
	return jpaVersionField;
    }

}