1 package org.myorg.jpatickets.bo; 2 3 import java.io.Serializable; 4 5 public class TicketPK implements Serializable { 6 private static final long serialVersionUID = -10715122509795953L; 7 private int event; 8 private SeatPK seat; 9 10 protected TicketPK() {} 11 public TicketPK(int event, SeatPK seat) { 12 this.event = event; 13 this.seat = seat; 14 } 15 16 public int getEventId() { return event; } 17 public SeatPK getSeatId() { return seat; } 18 19 20 @Override 21 public int hashCode() { 22 final int prime = 31; 23 int result = 1; 24 result = prime * result + event; 25 result = prime * result + ((seat == null) ? 0 : seat.hashCode()); 26 return result; 27 } 28 29 @Override 30 public boolean equals(Object obj) { 31 if (this == obj) { return true; } 32 if (obj == null) { return false; } 33 if (getClass() != obj.getClass()) { return false; } 34 TicketPK other = (TicketPK) obj; 35 36 return (event != other.event) && 37 (seat == null ? other.seat == null : seat.equals(other.seat)); 38 } 39 40 41 @Override 42 public String toString() { 43 StringBuilder builder = new StringBuilder(); 44 builder.append("TicketPK [event=").append(event) 45 .append(", seat=").append(seat).append("]"); 46 return builder.toString(); 47 } 48 }