View Javadoc
1   package ejava.projects.eleague.bo;
2   
3   import java.io.Serializable;
4   
5   import javax.persistence.CascadeType;
6   import javax.persistence.Column;
7   import javax.persistence.Entity;
8   import javax.persistence.GeneratedValue;
9   import javax.persistence.GenerationType;
10  import javax.persistence.Id;
11  import javax.persistence.JoinColumn;
12  import javax.persistence.OneToOne;
13  import javax.persistence.Table;
14  
15  /**
16   * This is an example eLeague Venue class. It will use full JPA annotations
17   * to define the mappings to the database. We could have also used an orm.xml
18   * file supplied by the DAO.
19   */
20  @Entity @Table(name="ELEAGUE_VEN")
21  public class Venue implements Serializable {
22  	private static final long serialVersionUID = 1L;
23  
24  	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
25  	private long id;
26  	
27  	@Column(length=40)
28      private String name;
29  
30      @OneToOne(cascade=CascadeType.ALL)
31      @JoinColumn(name="ADDR_ID", insertable=true, nullable=false)
32      private Address address;
33      
34      public Venue() {}
35      public Venue(long id) {
36          this(null, null);
37      }
38  
39      public Venue(String name, Address address) {
40          this.name = name;
41          this.address = address;
42      }
43      
44      public long getId() {
45          return id;
46      }
47      protected void setId(long id) {
48          this.id = id;
49      }
50      public String getName() {
51          return name;
52      }
53      public void setName(String name) {
54          this.name = name;
55      }
56      
57      public Address getAddress() {
58          return address;
59      }
60      public void setAddress(Address address) {
61          this.address = address;
62      }
63      
64      public String toString() {
65          StringBuilder text = new StringBuilder();
66          text.append("id=").append(id);
67          text.append(", name=").append(name);
68          text.append(", address=").append(address);        
69          return text.toString();
70      }
71      
72  }