FoodWave.java 4.02 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 java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

/**
 * 
 */
@Entity
@Table(name = "food_waves")
@NamedQueries( {
	@NamedQuery(name = "FoodWave.findAll", query = "SELECT f FROM FoodWave f"),
	@NamedQuery(name = "FoodWave.findById", query = "SELECT f FROM FoodWave f WHERE f.id = :id"),
	@NamedQuery(name = "FoodWave.findByName", query = "SELECT f FROM FoodWave f WHERE f.name = :name"),
	@NamedQuery(name = "FoodWave.findByDescription", query = "SELECT f FROM FoodWave f WHERE f.description = :description"),
	@NamedQuery(name = "FoodWave.findByTime", query = "SELECT f FROM FoodWave f WHERE f.time = :time"),
	@NamedQuery(name = "FoodWave.findByClosed", query = "SELECT f FROM FoodWave f WHERE f.closed = :closed") })
public class FoodWave implements ModelInterface {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "food_waves_id", nullable = false)
    private Integer id;

    @Column(name = "wave_name", nullable = false)
    private String name;

    @Column(name = "wave_description")
    private String description;

    @Column(name = "wave_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date time;

    @Column(name = "wave_closed", nullable = false, columnDefinition = "boolean default false")
    private boolean closed = false;

    @OneToMany(mappedBy = "foodWave")
    private List<AccountEvent> accountEvents;

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

    public FoodWave() {
    }

    public FoodWave(Integer foodWavesId) {
	this.id = foodWavesId;
    }

    public FoodWave(Integer foodWavesId, String waveName, boolean waveClosed) {
	this.id = foodWavesId;
	this.name = waveName;
	this.closed = waveClosed;
    }

    public String getName() {
	return name;
    }

    public void setName(String waveName) {
	this.name = waveName;
    }

    public String getDescription() {
	return description;
    }

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

    public Date getTime() {
	return time;
    }

    public void setTime(Date waveTime) {
	this.time = waveTime;
    }

    public boolean getClosed() {
	return closed;
    }

    public void setClosed(boolean waveClosed) {
	this.closed = waveClosed;
    }

    public List<AccountEvent> getAccountEvents() {
	return accountEvents;
    }

    public void setAccountEvents(List<AccountEvent> accountEventList) {
	this.accountEvents = accountEventList;
    }

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

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

    /**
     * @return the id
     */
    public Integer getId() {
	return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Integer id) {
	this.id = id;
    }

    /**
     * @return the jpaVersionField
     */
    public int getJpaVersionField() {
	return jpaVersionField;
    }

    /**
     * @param jpaVersionField
     *            the jpaVersionField to set
     */
    public void setJpaVersionField(int jpaVersionField) {
	this.jpaVersionField = jpaVersionField;
    }
}