KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > entity > Hashcodes


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.exceptions.entity;
20
21 import java.io.Serializable JavaDoc;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.NamedQueries;
27 import javax.persistence.NamedQuery;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30
31 /**
32  *
33  * @author Jan Horvath
34  */

35 @Entity
36 @Table(name = "HASHCODES")
37 @NamedQueries({@NamedQuery(name = "Hashcodes.findByCode", query = "SELECT h FROM Hashcodes h WHERE h.code = :code"),
38         @NamedQuery(name = "Hashcodes.findByIssueid", query = "SELECT h FROM Hashcodes h WHERE h.issueid = :issueid")})
39 public class Hashcodes implements Serializable JavaDoc {
40     
41     /** Creates a new instance of Hashcodes */
42         @Column(name = "CODE")
43     private Integer JavaDoc code;
44     @Id
45     @Column(name = "ISSUEID", nullable = false)
46     private Integer JavaDoc issueid;
47     @JoinColumn(name = "ISSUEID", referencedColumnName = "ID", insertable = false, updatable = false)
48     @OneToOne
49     private Issue issue;
50
51     /** Creates a new instance of Hashcodes */
52     public Hashcodes() {
53     }
54     
55     public Hashcodes(Integer JavaDoc issueid) {
56         this.issueid = issueid;
57     }
58
59     public Integer JavaDoc getCode() {
60         return code;
61     }
62
63     public void setCode(Integer JavaDoc code) {
64         this.code = code;
65     }
66
67     public Integer JavaDoc getIssueid() {
68         return issueid;
69     }
70
71     public void setIssueid(Integer JavaDoc issueid) {
72         this.issueid = issueid;
73     }
74
75     public Issue getIssue() {
76         return issue;
77     }
78
79     public void setIssue(Issue issue) {
80         this.issue = issue;
81     }
82
83     @Override JavaDoc
84     public int hashCode() {
85         int hash = 0;
86
87         hash += (issueid != null ? issueid.hashCode()
88                                  : 0);
89         return hash;
90     }
91
92     @Override JavaDoc
93     public boolean equals(Object JavaDoc object) {
94         if (!(object instanceof Hashcodes)) {
95             return false;
96         }
97         Hashcodes other = (Hashcodes) object;
98
99         if (this.issueid != other.issueid &&
100             (this.issueid == null || !this.issueid.equals(other.issueid)))
101             return false;
102         return true;
103     }
104
105     @Override JavaDoc
106     public String JavaDoc toString() {
107         return "test.Hashcodes[issueid=" + issueid + "]";
108     }
109
110 }
111
Popular Tags