View Javadoc
1   package ejava.projects.esales.bo;
2   
3   import java.io.Serializable;
4   
5   import javax.persistence.Column;
6   import javax.persistence.Entity;
7   import javax.persistence.GeneratedValue;
8   import javax.persistence.GenerationType;
9   import javax.persistence.Id;
10  import javax.persistence.Table;
11  
12  /**
13   * This class provides a thin example of how to setup an Address business
14   * object class for the project. Only a few fields are mapped and we
15   * will make full use of JPA annotations over an orm.xml file in this 
16   * example.
17   *
18   */
19  @SuppressWarnings("serial")
20  @Entity @Table(name="ESALES_ADDRESS")
21  public class Address implements Serializable {
22      @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="ID")
23  	private long id;
24  
25      @Column(name="NAME", length=10)
26  	private String name;
27  
28      @Column(name="CITY", length=20)
29  	private String city;
30  	
31  	public Address() {} 	
32  	public Address(long id) {
33  		setId(id); //use the set method to remove the unused warning
34  	}
35  	
36  	public Address(long id, String name, String city) {
37  		this.id = id;
38  		this.name = name;
39  		this.city = city;
40  	}
41  	
42  	public long getId() {
43  		return id;
44  	}
45  	private void setId(long id) {
46  		this.id = id;
47  	}
48  	
49  	public String getName() {
50  		return name;
51  	}
52  	public void setName(String name) {
53  		this.name = name;
54  	}
55  	
56  	public String getCity() {
57  		return city;
58  	}
59  	public void setCity(String city) {
60  		this.city = city;
61  	}
62  	
63  	public String toString() {
64  		StringBuilder text = new StringBuilder();
65  		text.append("id=" + id);
66  		text.append(", name=" + name);
67  		text.append(", city=" + city);
68  		return text.toString();
69  	}
70  }