1 package org.myorg.jpatickets.bo; 2 3 import java.io.Serializable; 4 5 import javax.persistence.*; 6 7 @SuppressWarnings("serial") 8 @Entity 9 @Table(name="JPATICKETS_VENUE") 10 public class Venue implements Serializable { 11 @Id 12 @Column(name="VENUE_ID", length=3) 13 private String id; 14 15 @Column(name="NAME", length=20, unique=true) 16 private String name; 17 18 @Embedded 19 private Address address; 20 21 public Venue() {} 22 public Venue(String id) { this.id = id; } 23 public String getId() { return id; } 24 25 public String getName() { return name; } 26 public void setName(String name) { 27 this.name = name; 28 } 29 public Venue withName(String name) { 30 setName(name); 31 return this; 32 } 33 34 public Address getAddress() { return address; } 35 public void setAddress(Address address) { 36 this.address = address; 37 } 38 public Venue withAddress(Address address) { 39 setAddress(address); 40 return this; 41 } 42 43 @Override 44 public int hashCode() { 45 final int prime = 31; 46 int result = 1; 47 result = prime * result + ((id == null) ? 0 : id.hashCode()); 48 result = prime * result + ((name == null) ? 0 : name.hashCode()); 49 return result; 50 } 51 52 @Override 53 public boolean equals(Object obj) { 54 if (this == obj) { return true; } 55 if (obj == null) { return false; } 56 if (getClass() != obj.getClass()) { return false; } 57 Venue other = (Venue) obj; 58 59 return (id == null ? other.id == null : id.equals(other.id)) && 60 (name == null ? other.name == null : name.equals(other.name)); 61 } 62 63 @Override 64 public String toString() { 65 StringBuilder builder = new StringBuilder(); 66 builder.append("Venue [id=").append(id) 67 .append(", name=").append(name) 68 .append(", address=").append(address) 69 .append("]"); 70 return builder.toString(); 71 } 72 }