KickJava   Java API By Example, From Geeks To Geeks.

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


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.EmbeddedId;
24 import javax.persistence.Entity;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.NamedQueries;
28 import javax.persistence.NamedQuery;
29 import javax.persistence.Table;
30
31 /**
32  *
33  * @author Jan Horvath
34  */

35 @Entity
36 @Table(name = "COMMENT")
37 @NamedQueries({@NamedQuery(name = "Comment.findById", query = "SELECT c FROM Comment c WHERE c.commentPK.id = :id"),
38         @NamedQuery(name = "Comment.findByIssueId", query = "SELECT c FROM Comment c WHERE c.commentPK.issueId = :issueId"),
39         @NamedQuery(name = "Comment.findByComment", query = "SELECT c FROM Comment c WHERE c.comment = :comment"),
40         @NamedQuery(name = "Comment.findByLoggername", query = "SELECT c FROM Comment c WHERE c.loggername = :loggername")})
41 public class Comment implements Serializable JavaDoc {
42     
43     /** Creates a new instance of Comment */
44         @EmbeddedId
45     protected CommentPK commentPK;
46     @Column(name = "COMMENT")
47     private String JavaDoc comment;
48     @Column(name = "LOGGERNAME")
49     private String JavaDoc loggername;
50     @JoinColumn(name = "ISSUE_ID", referencedColumnName = "ID", insertable = false, updatable = false)
51     @ManyToOne
52     private Issue issue;
53     @JoinColumn(name = "NBUSER_ID", referencedColumnName = "ID")
54     @ManyToOne
55     private Nbuser nbuserId;
56
57     /** Creates a new instance of Comment */
58     public Comment() {
59     }
60     
61     public Comment(CommentPK commentPK) {
62         this.commentPK = commentPK;
63     }
64
65     public Comment(int id, int issueId) {
66         this.commentPK = new CommentPK(id, issueId);
67     }
68
69     public CommentPK getCommentPK() {
70         return commentPK;
71     }
72
73     public void setCommentPK(CommentPK commentPK) {
74         this.commentPK = commentPK;
75     }
76
77     public String JavaDoc getComment() {
78         return comment;
79     }
80
81     public void setComment(String JavaDoc comment) {
82         this.comment = comment;
83     }
84
85     public String JavaDoc getLoggername() {
86         return loggername;
87     }
88
89     public void setLoggername(String JavaDoc loggername) {
90         this.loggername = loggername;
91     }
92
93     public Issue getIssue() {
94         return issue;
95     }
96
97     public void setIssue(Issue issue) {
98         this.issue = issue;
99     }
100
101     public Nbuser getNbuserId() {
102         return nbuserId;
103     }
104
105     public void setNbuserId(Nbuser nbuserId) {
106         this.nbuserId = nbuserId;
107     }
108
109     @Override JavaDoc
110     public int hashCode() {
111         int hash = 0;
112
113         hash += (commentPK != null ? commentPK.hashCode()
114                                    : 0);
115         return hash;
116     }
117
118     @Override JavaDoc
119     public boolean equals(Object JavaDoc object) {
120         if (!(object instanceof Comment)) {
121             return false;
122         }
123         Comment other = (Comment) object;
124
125         if (this.commentPK != other.commentPK &&
126             (this.commentPK == null || !this.commentPK.equals(other.commentPK)))
127             return false;
128         return true;
129     }
130
131     @Override JavaDoc
132     public String JavaDoc toString() {
133         return "test.Comment[commentPK=" + commentPK + "]";
134     }
135
136 }
137
Popular Tags