1 9 10 14 15 package enterprise.customer_cmp_ejb.persistence; 16 17 import java.util.ArrayList ; 18 import java.util.Collection ; 19 import java.util.Iterator ; 20 21 import javax.persistence.*; 22 23 24 @Entity 25 @NamedQuery(name="findAllSubscriptions", query="select s from Subscription s") 26 27 public class Subscription implements java.io.Serializable { 28 29 private String title; 30 private String type; 31 private Collection <Customer> customers; 32 33 public Subscription(){ 34 35 } 36 37 @Id 38 public String getTitle(){ return title; 40 } 41 public void setTitle(String title){ 42 this.title=title; 43 } 44 45 public String getType(){ 46 return type; 47 } 48 public void setType(String type){ 49 this.type=type; 50 } 51 52 @ManyToMany(mappedBy="subscriptions") 54 public Collection <Customer> getCustomers(){ 55 return customers; 56 } 57 public void setCustomers(Collection <Customer> customers){ 58 this.customers=customers; 59 } 60 61 public Subscription ( 62 String title, 63 String type) { 64 65 if (type.equals(SubscriptionType.MAGAZINE)) { 66 _create(title,SubscriptionType.MAGAZINE); 67 } 68 else if (type.equals(SubscriptionType.JOURNAL)) { 69 _create(title,SubscriptionType.JOURNAL); 70 } 71 else if (type.equals(SubscriptionType.NEWS_PAPER)) { 72 _create(title,SubscriptionType.NEWS_PAPER); 73 } 74 else 75 _create(title,SubscriptionType.OTHER); 76 77 } 78 79 80 private String _create ( 81 String title, 82 String type) { 83 84 85 setTitle(title); 86 setType(type); 87 return title; 88 } 89 90 } 91 92 93 94 | Popular Tags |