KickJava   Java API By Example, From Geeks To Geeks.

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


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

34 @Entity
35 @Table(name = "LINE")
36 @NamedQueries({@NamedQuery(name = "Line.findByStacktraceId", query = "SELECT l FROM Line l WHERE l.linePK.stacktraceId = :stacktraceId"),
37         @NamedQuery(name = "Line.findByMethodId", query = "SELECT l FROM Line l WHERE l.linePK.methodId = :methodId"),
38         @NamedQuery(name = "Line.findByLinenumber", query = "SELECT l FROM Line l WHERE l.linePK.linenumber = :linenumber"),
39         @NamedQuery(name = "Line.findByLineOrder", query = "SELECT l FROM Line l WHERE l.linePK.lineOrder = :lineOrder")})
40 public class Line implements Serializable JavaDoc {
41     
42     /** Creates a new instance of Line */
43         @EmbeddedId
44     protected LinePK linePK;
45     @JoinColumn(name = "METHOD_ID", referencedColumnName = "ID", insertable = false, updatable = false)
46     @ManyToOne
47     private Method method;
48
49     @JoinColumn(name = "STACKTRACE_ID", referencedColumnName = "ID", insertable = false, updatable = false)
50     @ManyToOne
51     private Stacktrace stacktrace;
52
53     /** Creates a new instance of Line */
54     public Line() {
55     }
56     
57     public Line(LinePK linePK) {
58         this.linePK = linePK;
59     }
60
61     public Line(int stacktraceId, int methodId, int linenumber, int lineOrder) {
62         this.linePK = new LinePK(stacktraceId, methodId, linenumber, lineOrder);
63     }
64
65     public LinePK getLinePK() {
66         return linePK;
67     }
68
69     public void setLinePK(LinePK linePK) {
70         this.linePK = linePK;
71     }
72
73     public Method getMethod() {
74         return method;
75     }
76
77     public void setMethod(Method method) {
78         this.method = method;
79     }
80
81
82     public Stacktrace getStacktrace() {
83         return stacktrace;
84     }
85
86     public void setStacktrace(Stacktrace stacktrace) {
87         this.stacktrace = stacktrace;
88     }
89
90     @Override JavaDoc
91     public int hashCode() {
92         int hash = 0;
93
94         hash += (linePK != null ? linePK.hashCode()
95                                 : 0);
96         return hash;
97     }
98
99     @Override JavaDoc
100     public boolean equals(Object JavaDoc object) {
101         if (!(object instanceof Line)) {
102             return false;
103         }
104         Line other = (Line) object;
105
106         if (this.linePK != other.linePK &&
107             (this.linePK == null || !this.linePK.equals(other.linePK)))
108             return false;
109         return true;
110     }
111
112     @Override JavaDoc
113     public String JavaDoc toString() {
114         return "test.Line[linePK=" + linePK + "]";
115     }
116
117 }
118
Popular Tags