Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorial:pojo_schema [2020/04/16 10:56]
tutorial:pojo_schema [2020/04/16 10:56] (current)
Line 1: Line 1:
 +Class **Address**
 +<code java>
 +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<​Customer>​ customers = new HashSet<​Customer>​(0);​
 +    private Set<​Store>​ stores = new HashSet<​Store>​(0);​
 +    private Set<​Staff>​ staffs = new HashSet<​Staff>​(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<​Customer>​ getCustomers() {
 +        return this.customers;​
 +    }
 +    public void setCustomers(Set<​Customer>​ customers) {
 +        this.customers = customers;
 +    }
 +
 +    @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;
 +    }
 +}
 +</​code>​
 +\\ \\
 +Class **City**
 +<code java>
 +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<​Address>​ addresses = new HashSet<​Address>​(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<​Address>​ getAddresses() {
 +        return this.addresses;​
 +    }
 +    public void setAddresses(Set<​Address>​ addresses) {
 +        this.addresses = addresses;
 +    }
 +}
 +</​code>​
 +\\ \\
 +Class **Country**
 +<code java>
 +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<​City>​ cities = new HashSet<​City>​(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<​City>​ getCities() {
 +        return this.cities;​
 +    }
 +    public void setCities(Set<​City>​ cities) {
 +        this.cities = cities;
 +    }
 +}
 +</​code>​