Class Address

package org.mycompany.myproject.model;
import ...
@Entity
@Table(name = "address", catalog = "sakila")
public class Address implements java.io.Serializable {
	private Short addressId;
	private City city;
	private String address;
	private String address2;
	private String district;
	private String postalCode;
	private String phone;
	private Date lastUpdate;
	private Set<Store> stores = new HashSet<Store>(0);
	private Set<Staff> staffs = new HashSet<Staff>(0);
	private Set<Customer> customers = new HashSet<Customer>(0);
	public Address() {
	}
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "address_id", unique = true, nullable = false)
	public Short getAddressId() {
		return this.addressId;
	}
	public void setAddressId(Short 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 = 19)
	public Date getLastUpdate() {
		return this.lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "address")
	public Set<Store> getStores() {
		return this.stores;
	}
	public void setStores(Set<Store> stores) {
		this.stores = stores;
	}
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "address")
	public Set<Staff> getStaffs() {
		return this.staffs;
	}
	public void setStaffs(Set<Staff> staffs) {
		this.staffs = staffs;
	}
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "address")
	public Set<Customer> getCustomers() {
		return this.customers;
	}
	public void setCustomers(Set<Customer> customers) {
		this.customers = customers;
	}
}



Class City

package org.mycompany.myproject.model;
import ...
@Entity
@Table(name = "city", catalog = "sakila")
public class City implements java.io.Serializable {
	private Short cityId;
	private Country country;
	private String city;
	private Date lastUpdate;
	private Set<Address> addresses = new HashSet<Address>(0);
	public City() {
	}
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "city_id", unique = true, nullable = false)
	public Short getCityId() {
		return this.cityId;
	}
	public void setCityId(Short 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 = 19)
	public Date getLastUpdate() {
		return this.lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "city")
	public Set<Address> getAddresses() {
		return this.addresses;
	}
	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}
}



Class Country

package org.mycompany.myproject.model;
import ...
@Entity
@Table(name = "country", catalog = "sakila")
public class Country implements java.io.Serializable {
	private Short countryId;
	private String country;
	private Date lastUpdate;
	private Set<City> cities = new HashSet<City>(0);
	public Country() {
	}
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "country_id", unique = true, nullable = false)
	public Short getCountryId() {
		return this.countryId;
	}
	public void setCountryId(Short 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 = 19)
	public Date getLastUpdate() {
		return this.lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "country")
	public Set<City> getCities() {
		return this.cities;
	}
	public void setCities(Set<City> cities) {
		this.cities = cities;
	}
}
tutorial/pojo_schema.txt · Last modified: 2015/10/05 17:52 (external edit)