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
|
@Entity
@Table(name = "T_CONTINENT")
public class Continent extends AbstractModelObject implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "continent_id")
private long continentId;// Identifiant du continent
@Version
private int version;
@Column(name = "continent_name")
private String continentName;// Nom du continent
@OneToMany(mappedBy = "continent", cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
private Set<Country> countries = new HashSet<Country>();
public Continent() {}
public Contienent(String continentName) {
super();
this.continentName = continentName;
}
//GETTER AND SETTER
public void addCountry(Country country) {
countries.add(country);
country.setContinent(this);
firePropertyChange("countries", null, this.countries);
}
public void deleteCountry(Country country) {
}
@Override
public int hashCode() {
int result;
result = getContinentName().hashCode();
result = (int) (31 * result + getContinentId());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Continent))
return false;
Continent other = (Continent) obj;
if (getContinentId() != other.getContinentId())
return false;
if (getContinentName() == null) {
if (other.getContinentName() != null)
return false;
} else if (!getContinentName().equals(other.getContinentName()))
return false;
return true;
}
} |
Partager