1 22 package org.jboss.ejb3.test.entitycallback; 23 24 import javax.persistence.DiscriminatorColumn; 25 import javax.persistence.DiscriminatorType; 26 import javax.persistence.Entity; 27 import javax.persistence.EntityListeners; 28 import javax.persistence.GeneratedValue; 29 import javax.persistence.GenerationType; 30 import javax.persistence.Id; 31 import javax.persistence.Inheritance; 32 import javax.persistence.InheritanceType; 33 import javax.persistence.JoinColumn; 34 import javax.persistence.ManyToOne; 35 36 40 @Entity 41 @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 42 @DiscriminatorColumn(name = "JOURNEY_TYPE", discriminatorType = DiscriminatorType.STRING) 43 @EntityListeners(JourneyCallbackListener.class) 44 public class Journey 45 { 46 Long id; 47 private String start; 48 private String dest; 49 50 private Customer customer; 51 52 public Journey() 53 { 54 55 } 56 57 public Journey(String start, String dest) 58 { 59 this.start = start; 60 this.dest = dest; 61 } 62 63 @Id @GeneratedValue(strategy=GenerationType.AUTO) 64 public Long getId() 65 { 66 return id; 67 } 68 69 public void setId(Long id) 70 { 71 this.id = id; 72 } 73 74 public String getStart() 75 { 76 return start; 77 } 78 79 public void setStart(String start) 80 { 81 this.start = start; 82 } 83 84 public String getDest() 85 { 86 return dest; 87 } 88 89 public void setDest(String dest) 90 { 91 this.dest = dest; 92 } 93 94 public void setCustomer(Customer customer) 95 { 96 this.customer = customer; 97 } 98 99 @ManyToOne 100 @JoinColumn(name = "CUSTOMER_ID") 101 public Customer getCustomer() 102 { 103 return customer; 104 } 105 } 106 | Popular Tags |