/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaone.con3638.pfscaffolding.entities;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
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.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Martin Fousek <marfous@netbeans.org>
*/
@Entity
@Table(name = "OWNER")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Owner.findAll", query = "SELECT o FROM Owner o"),
@NamedQuery(name = "Owner.findById", query = "SELECT o FROM Owner o WHERE o.id = :id"),
@NamedQuery(name = "Owner.findByName", query = "SELECT o FROM Owner o WHERE o.name = :name")})
public class Owner implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private Long id;
@Size(max = 255)
@Column(name = "NAME")
private String name;
@OneToMany(mappedBy = "ownerId")
private Collection<Car> carCollection;
public Owner() {
}
public Owner(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlTransient
public Collection<Car> getCarCollection() {
return carCollection;
}
public void setCarCollection(Collection<Car> carCollection) {
this.carCollection = carCollection;
}
@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 Owner)) {
return false;
}
Owner other = (Owner) 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 "entities.Owner[ id=" + id + " ]";
}
}