KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > Country


1 //$Id: Country.java,v 1.1 2005/05/12 13:33:52 epbernard Exp $
2
package org.hibernate.test.annotations;
3
4 /**
5  * @author Emmanuel Bernard
6  */

7
8 import javax.persistence.Entity;
9 import javax.persistence.GeneratorType;
10 import javax.persistence.Id;
11 import java.io.Serializable JavaDoc;
12
13 @Entity()
14 public class Country implements Serializable JavaDoc {
15     private Integer JavaDoc id;
16     private String JavaDoc name;
17     
18     @Id(generate = GeneratorType.AUTO)
19     public Integer JavaDoc getId() {
20         return id;
21     }
22
23     public String JavaDoc getName() {
24         return name;
25     }
26
27     public void setId(Integer JavaDoc integer) {
28         id = integer;
29     }
30
31     public void setName(String JavaDoc string) {
32         name = string;
33     }
34     
35     public int hashCode() {
36         return name == null ? 0:name.hashCode();
37     }
38     
39     public boolean equals(Object JavaDoc obj) {
40         if (obj == this) return true;
41         if (! (obj instanceof Country) ) return false;
42         Country that = (Country) obj;
43         if (this.name == null) return false;
44         return this.name.equals(that.name);
45     }
46 }
47
Popular Tags