KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > House


1 package example;
2
3 import javax.persistence.*;
4
5 import java.util.Collection JavaDoc;
6
7 /**
8  * Implementation class for the House bean.
9  *
10  * <code><pre>
11  * CREATE TABLE amber_query_house (
12  * id BIGINT PRIMARY KEY auto_increment,
13  * name VARCHAR(250) UNIQUE NOT NULL
14  * );
15  * </pre></code>
16  */

17 @Entity
18 @Table(name="amber_query_house")
19 public class House {
20   private long _id;
21   private String JavaDoc _name;
22
23   private Collection JavaDoc _studentList;
24
25   public House()
26   {
27   }
28
29   public House(String JavaDoc name)
30   {
31     _name = name;
32   }
33   
34   /**
35    * Returns the id of the house.
36    */

37   @Id
38   @Column(name="id")
39   @GeneratedValue
40   public long getId()
41   {
42     return _id;
43   }
44   
45   /**
46    * Sets the id of the house.
47    */

48   public void setId(long id)
49   {
50     _id = id;
51   }
52   
53   /**
54    * Returns the name of the house.
55    */

56   @Basic
57   @Column(unique=true)
58   public String JavaDoc getName()
59   {
60     return _name;
61   }
62   
63   /**
64    * Sets the name of the house.
65    */

66   public void setName(String JavaDoc name)
67   {
68     _name = name;
69   }
70
71   /**
72    * returns a <code>Collection</code> of all Students living in this House.
73    */

74   @OneToMany(mappedBy="house")
75   public Collection JavaDoc<Student> getStudentList()
76   {
77     return _studentList;
78   }
79
80   /**
81    * returns a <code>Collection</code> of all Students living in this House.
82    */

83   public void setStudentList(Collection JavaDoc<Student> list)
84   {
85   }
86 }
87
Popular Tags