/*
* Copyright (C) 2013 Martin Fousek & Mert Caliskan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package javaone.con3638.jsfscaffolding.entities;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author marfous
*/
@Entity
@Table(name = "CAR")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Car.findAll", query = "SELECT c FROM Car c"),
@NamedQuery(name = "Car.findById", query = "SELECT c FROM Car c WHERE c.id = :id"),
@NamedQuery(name = "Car.findByKilometers", query = "SELECT c FROM Car c WHERE c.kilometers = :kilometers"),
@NamedQuery(name = "Car.findByMark", query = "SELECT c FROM Car c WHERE c.mark = :mark")})
public class Car implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private Long id;
@Column(name = "KILOMETERS")
private Integer kilometers;
@Size(max = 255)
@Column(name = "MARK")
private String mark;
@JoinColumn(name = "OWNER_ID", referencedColumnName = "ID")
@ManyToOne
private Owner ownerId;
public Car() {
}
public Car(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getKilometers() {
return kilometers;
}
public void setKilometers(Integer kilometers) {
this.kilometers = kilometers;
}
public String getMark() {
return mark;
}
public void setMark(String mark) {
this.mark = mark;
}
public Owner getOwnerId() {
return ownerId;
}
public void setOwnerId(Owner ownerId) {
this.ownerId = ownerId;
}
@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 Car)) {
return false;
}
Car other = (Car) 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 "javaone.con3638.jsfscaffolding.entities.Car[ id=" + id + " ]";
}
}