1 22 package org.jboss.ejb3.test.entitycallback; 23 24 import javax.persistence.DiscriminatorColumn; 25 import javax.persistence.DiscriminatorType; 26 import javax.persistence.DiscriminatorValue; 27 import javax.persistence.Entity; 28 import javax.persistence.Inheritance; 29 import javax.persistence.InheritanceType; 30 import javax.persistence.PostLoad; 31 import javax.persistence.PostPersist; 32 import javax.persistence.PostRemove; 33 import javax.persistence.PostUpdate; 34 import javax.persistence.PrePersist; 35 import javax.persistence.PreRemove; 36 import javax.persistence.PreUpdate; 37 38 42 @Entity 43 @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 44 @DiscriminatorValue("TRAIN") 45 @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING) 46 public class TrainJourney extends Journey 47 { 48 private String train; 49 50 public TrainJourney() 51 { 52 53 } 54 55 public TrainJourney(String start, String dest, String train) 56 { 57 super(start, dest); 58 this.train = train; 59 } 60 61 public String getTrain() 62 { 63 return train; 64 } 65 66 public void setTrain(String train) 67 { 68 this.train = train; 69 } 70 71 @PrePersist 72 public void doPreCreate() 73 { 74 System.out.println("TrainJourney doPreCreate"); 75 CallbackCounterBean.addCallback("TrainJourney", PrePersist.class); 76 } 77 78 @PostPersist 79 public void doPostCreate() 80 { 81 System.out.println("TrainJourney doPostCreate"); 82 CallbackCounterBean.addCallback("TrainJourney", PostPersist.class); 83 } 84 85 @PreRemove 86 public void doPreRemove() 87 { 88 System.out.println("TrainJourney doPreRemove"); 89 CallbackCounterBean.addCallback("TrainJourney", PreRemove.class); 90 } 91 92 @PostRemove 93 public void doPostRemove() 94 { 95 System.out.println("TrainJourney doPostRemove"); 96 CallbackCounterBean.addCallback("TrainJourney", PostRemove.class); 97 } 98 99 @PreUpdate 100 public void doPreUpdate() 101 { 102 System.out.println("TrainJourney doPreUpdate"); 103 CallbackCounterBean.addCallback("TrainJourney", PreUpdate.class); 104 } 105 106 @PostUpdate 107 public void doPostUpdate() 108 { 109 System.out.println("TrainJourney doPostUpdate"); 110 CallbackCounterBean.addCallback("TrainJourney", PostUpdate.class); 111 } 112 113 @PostLoad 114 public void doPostLoad() 115 { 116 System.out.println("TrainJourney doPostLoad"); 117 CallbackCounterBean.addCallback("TrainJourney", PostLoad.class); 118 } 119 120 } 121 | Popular Tags |