1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| package website.domain.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
/**
*
* @author funkalee
*/
@Entity
@Table(name = "City")
@NamedQueries({
@NamedQuery(name = "City.findAll", query = "SELECT c FROM City c"),
@NamedQuery(name = "City.findByCityID", query = "SELECT c FROM City c WHERE c.cityID = :cityID"),
@NamedQuery(name = "City.findByCityName", query = "SELECT c FROM City c WHERE c.cityName = :cityName"),
@NamedQuery(name = "City.findByCityINSEECode", query = "SELECT c FROM City c WHERE c.cityINSEECode = :cityINSEECode")})
public class City implements Serializable {
private static final long serialVersionUID = 1L;
public static final String PROP_CITYID = "cityID";
public static final String PROP_CITYNAME = "cityName";
public static final String PROP_CITYINSEECODE = "cityINSEECode";
public static final String PROP_CITY_ZIPCODEID = "zipCode";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "cityID", nullable = false)
private Long cityID;
@Basic(optional = false)
@Column(name = "cityName", nullable = false, length = 32)
private String cityName;
@Column(name = "cityINSEECode", length = 5)
@Index(name="idx_City_cityINSEECode")
private String cityINSEECode;
@JoinColumn(name = "zipCode", referencedColumnName = "zipCodeID", nullable = false)
@ManyToOne(optional = false)
private ZipCode zipCode;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "city")
private List<Address> addressList;
public City() {
}
public City(Long cityID) {
this.cityID = cityID;
}
public City(Long cityID, String cityName) {
this.cityID = cityID;
this.cityName = cityName;
}
public Long getCityID() {
return cityID;
}
public void setCityID(Long cityID) {
this.cityID = cityID;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCityINSEECode() {
return cityINSEECode;
}
public void setCityINSEECode(String cityINSEECode) {
this.cityINSEECode = cityINSEECode;
}
public ZipCode getZipCode() {
return zipCode;
}
public void setZipCode(ZipCode zipCode) {
this.zipCode = zipCode;
}
public List<Address> getAddressList() {
return addressList;
}
public void setAddressList(List<Address> addressList) {
this.addressList = addressList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (cityID != null ? cityID.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// this method won't work in the case the id fields are not set
if (!(object instanceof City)) {
return false;
}
City other = (City) object;
if ((this.cityID == null && other.cityID != null) || (this.cityID != null && !this.cityID.equals(other.cityID))) {
return false;
}
return true;
}
@Override
public String toString() {
StringBuilder entityToString = new StringBuilder(City.class.getSimpleName());
entityToString.append(" :[").append(PROP_CITYID).append(" = ");
entityToString.append(this.getCityID()).append("][").append(PROP_CITYNAME);
entityToString.append(" = ").append(this.getCityName()).append("][");
entityToString.append(PROP_CITYINSEECODE).append(" = ");
entityToString.append(this.getCityINSEECode()).append("][");
entityToString.append(PROP_CITY_ZIPCODEID).append(" = ");
entityToString.append(this.getZipCode() == null ? "null"
: this.getZipCode().getZipCodeID());
entityToString.append("][").append("memory reference = ");
entityToString.append(City.class.getName()).append("@");
entityToString.append(Integer.toHexString(this.hashCode())).append("]");
return entityToString.toString();
}
} |
Partager