Class **Address** package org.mycompany.myproject.model; import ... /** * Address generated by hbm2java */ @Entity @Table(name="address", schema="public") public class Address extends ASuperLastUpdate implements java.io.Serializable { private static final long serialVersionUID = 1L; private int addressId; private City city; private String address; private String address2; private String district; private String postalCode; private String phone; private Date lastUpdate; private Set customers = new HashSet(0); private Set stores = new HashSet(0); private Set staffs = new HashSet(0); @Id @GeneratedValue(strategy = IDENTITY) @Column(name="address_id", unique=true, nullable=false) public int getAddressId() { return this.addressId; } public void setAddressId(int addressId) { this.addressId = addressId; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="city_id", nullable=false) public City getCity() { return this.city; } public void setCity(City city) { this.city = city; } @Column(name="address", nullable=false, length=50) public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } @Column(name="address2", length=50) public String getAddress2() { return this.address2; } public void setAddress2(String address2) { this.address2 = address2; } @Column(name="district", nullable=false, length=20) public String getDistrict() { return this.district; } public void setDistrict(String district) { this.district = district; } @Column(name="postal_code", length=10) public String getPostalCode() { return this.postalCode; } public void setPostalCode(String postalCode) { this.postalCode = postalCode; } @Column(name="phone", nullable=false, length=20) public String getPhone() { return this.phone; } public void setPhone(String phone) { this.phone = phone; } @Temporal(TemporalType.TIMESTAMP) @Column(name="last_update", nullable=false, length=29) public Date getLastUpdate() { return this.lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } @OneToMany(fetch=FetchType.LAZY, mappedBy="address") public Set getCustomers() { return this.customers; } public void setCustomers(Set customers) { this.customers = customers; } @OneToMany(fetch=FetchType.LAZY, mappedBy="address") public Set getStores() { return this.stores; } public void setStores(Set stores) { this.stores = stores; } @OneToMany(fetch=FetchType.LAZY, mappedBy="address") public Set getStaffs() { return this.staffs; } public void setStaffs(Set staffs) { this.staffs = staffs; } } \\ \\ Class **City** package org.mycompany.myproject.model; import ... /** * City generated by hbm2java */ @Entity @Table(name="city", schema="public") public class City extends ASuperLastUpdate implements java.io.Serializable { private static final long serialVersionUID = 1L; private int cityId; private Country country; private String city; private Date lastUpdate; private Set
addresses = new HashSet
(0); @Id @GeneratedValue(strategy = IDENTITY) @Column(name="city_id", unique=true, nullable=false) public int getCityId() { return this.cityId; } public void setCityId(int cityId) { this.cityId = cityId; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="country_id", nullable=false) public Country getCountry() { return this.country; } public void setCountry(Country country) { this.country = country; } @Column(name="city", nullable=false, length=50) public String getCity() { return this.city; } public void setCity(String city) { this.city = city; } @Temporal(TemporalType.TIMESTAMP) @Column(name="last_update", nullable=false, length=29) public Date getLastUpdate() { return this.lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } @OneToMany(fetch=FetchType.LAZY, mappedBy="city") public Set
getAddresses() { return this.addresses; } public void setAddresses(Set
addresses) { this.addresses = addresses; } } \\ \\ Class **Country** package org.mycompany.myproject.model; import ... /** * Country generated by hbm2java */ @Entity @Table(name="country", schema="public") public class Country extends ASuperLastUpdate implements java.io.Serializable { private static final long serialVersionUID = 1L; private int countryId; private String country; private Date lastUpdate; private Set cities = new HashSet(0); @Id @GeneratedValue(strategy = IDENTITY) @Column(name="country_id", unique=true, nullable=false) public int getCountryId() { return this.countryId; } public void setCountryId(int countryId) { this.countryId = countryId; } @Column(name="country", nullable=false, length=50) public String getCountry() { return this.country; } public void setCountry(String country) { this.country = country; } @Temporal(TemporalType.TIMESTAMP) @Column(name="last_update", nullable=false, length=29) public Date getLastUpdate() { return this.lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } @OneToMany(fetch=FetchType.LAZY, mappedBy="country") public Set getCities() { return this.cities; } public void setCities(Set cities) { this.cities = cities; } }