KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ejb > test > Item


1 //$Id: Item.java,v 1.6 2005/07/09 20:04:44 epbernard Exp $
2
package org.hibernate.ejb.test;
3
4 import java.util.HashSet JavaDoc;
5 import java.util.Set JavaDoc;
6 import javax.persistence.Column;
7 import javax.persistence.Entity;
8 import javax.persistence.EntityResult;
9 import javax.persistence.FieldResult;
10 import javax.persistence.Id;
11 import javax.persistence.OneToMany;
12 import javax.persistence.SqlResultSetMapping;
13
14 /**
15  * @author Gavin King
16  */

17 @Entity(name = "Item")
18         @SqlResultSetMapping(name = "getItem", entities =
19         @EntityResult(name = "org.hibernate.ejb.test.Item", fields = {
20         @FieldResult(name = "name", column = "itemname"),
21         @FieldResult(name = "descr", column = "itemdescription")
22         })
23         )
24 //@Cache(region="Item", usage=NONSTRICT_READ_WRITE)
25
public class Item {
26
27     private String JavaDoc name;
28     private String JavaDoc descr;
29     private Set JavaDoc<Distributor> distributors;
30
31     public Item() {
32     }
33
34     public Item(String JavaDoc name, String JavaDoc desc) {
35         this.name = name;
36         this.descr = desc;
37     }
38
39     @Column(length = 200)
40             public String JavaDoc getDescr() {
41         return descr;
42     }
43
44     public void setDescr(String JavaDoc desc) {
45         this.descr = desc;
46     }
47
48     @Id @Column(length = 30)
49             public String JavaDoc getName() {
50         return name;
51     }
52
53     public void setName(String JavaDoc name) {
54         this.name = name;
55     }
56
57     @OneToMany
58             public Set JavaDoc<Distributor> getDistributors() {
59         return distributors;
60     }
61
62     public void setDistributors(Set JavaDoc<Distributor> distributors) {
63         this.distributors = distributors;
64     }
65
66     public void addDistributor(Distributor d) {
67         if ( distributors == null ) distributors = new HashSet JavaDoc();
68         distributors.add( d );
69     }
70 }
71
Popular Tags