Address.java

  1. package ejava.projects.esales.bo;

  2. import java.io.Serializable;

  3. import javax.persistence.Column;
  4. import javax.persistence.Entity;
  5. import javax.persistence.GeneratedValue;
  6. import javax.persistence.GenerationType;
  7. import javax.persistence.Id;
  8. import javax.persistence.Table;

  9. /**
  10.  * This class provides a thin example of how to setup an Address business
  11.  * object class for the project. Only a few fields are mapped and we
  12.  * will make full use of JPA annotations over an orm.xml file in this
  13.  * example.
  14.  *
  15.  */
  16. @SuppressWarnings("serial")
  17. @Entity @Table(name="ESALES_ADDRESS")
  18. public class Address implements Serializable {
  19.     @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="ID")
  20.     private long id;

  21.     @Column(name="NAME", length=10)
  22.     private String name;

  23.     @Column(name="CITY", length=20)
  24.     private String city;
  25.    
  26.     public Address() {}    
  27.     public Address(long id) {
  28.         setId(id); //use the set method to remove the unused warning
  29.     }
  30.    
  31.     public Address(long id, String name, String city) {
  32.         this.id = id;
  33.         this.name = name;
  34.         this.city = city;
  35.     }
  36.    
  37.     public long getId() {
  38.         return id;
  39.     }
  40.     private void setId(long id) {
  41.         this.id = id;
  42.     }
  43.    
  44.     public String getName() {
  45.         return name;
  46.     }
  47.     public void setName(String name) {
  48.         this.name = name;
  49.     }
  50.    
  51.     public String getCity() {
  52.         return city;
  53.     }
  54.     public void setCity(String city) {
  55.         this.city = city;
  56.     }
  57.    
  58.     public String toString() {
  59.         StringBuilder text = new StringBuilder();
  60.         text.append("id=" + id);
  61.         text.append(", name=" + name);
  62.         text.append(", city=" + city);
  63.         return text.toString();
  64.     }
  65. }