1 package xpetstore.domain.catalog.ejb; 2 3 import java.util.Collection ; 4 5 import javax.persistence.CascadeType; 6 import javax.persistence.Column; 7 import javax.persistence.Entity; 8 import javax.persistence.Id; 9 import javax.persistence.JoinColumn; 10 import javax.persistence.OneToMany; 11 import javax.persistence.Table; 12 13 14 41 @Entity(name="Category") 42 @Table(name="T_CATEGORY") 43 public class Category 44 { 45 private String categoryId; 46 private String name; 47 private String description; 48 private Collection products; 49 50 public Category() 51 { 52 53 } 54 55 65 @Id 66 @Column(name="categoryId") 67 public String getCategoryId( ) 68 { 69 return categoryId; 70 } 71 72 public void setCategoryId( String categoryId ) 73 { 74 this.categoryId = categoryId; 75 } 76 77 83 @Column(name="name", length=50) 84 public String getName( ) 85 { 86 return name; 87 } 88 89 public void setName( String name ) 90 { 91 this.name = name; 92 } 93 94 100 @Column(name="description", length=255) 101 public String getDescription( ) 102 { 103 return description; 104 } 105 106 public void setDescription( String description ) 107 { 108 this.description = description; 109 } 110 111 117 @OneToMany(targetEntity=Product.class, cascade={CascadeType.ALL}) 118 @JoinColumn(name="CATEGORY_ID") 119 public Collection getProducts( ) 120 { 121 return products; 122 } 123 124 public void setProducts( Collection products ) 125 { 126 this.products = products; 127 } 128 } 129 | Popular Tags |