KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Collection JavaDoc;
23 import javax.persistence.CascadeType;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.Id;
27 import javax.persistence.NamedQueries;
28 import javax.persistence.NamedQuery;
29 import javax.persistence.OneToMany;
30 import javax.persistence.Table;
31
32 /**
33  *
34  * @author Jan Horvath
35  */

36 @Entity
37 @Table(name = "METHOD")
38 @NamedQueries({@NamedQuery(name = "Method.findById", query = "SELECT m FROM Method m WHERE m.id = :id"),
39         @NamedQuery(name = "Method.findByName", query = "SELECT m FROM Method m WHERE m.name = :name")})
40 public class Method implements Serializable JavaDoc {
41     
42     /** Creates a new instance of Method */
43         @Id
44     @Column(name = "ID", nullable = false)
45     private Integer JavaDoc id;
46     @Column(name = "NAME")
47     private String JavaDoc name;
48     @OneToMany(cascade = CascadeType.ALL, mappedBy = "method")
49     private Collection JavaDoc<Line> lineCollection;
50
51     /** Creates a new instance of Method */
52     public Method() {
53     }
54     
55     public Method(Integer JavaDoc id) {
56         this.id = id;
57     }
58
59     public Integer JavaDoc getId() {
60         return id;
61     }
62
63     public void setId(Integer JavaDoc id) {
64         this.id = id;
65     }
66
67     public String JavaDoc getName() {
68         return name;
69     }
70
71     public void setName(String JavaDoc name) {
72         this.name = name;
73     }
74
75     public Collection JavaDoc<Line> getLineCollection() {
76         return lineCollection;
77     }
78
79     public void setLineCollection(Collection JavaDoc<Line> lineCollection) {
80         this.lineCollection = lineCollection;
81     }
82
83     @Override JavaDoc
84     public int hashCode() {
85         int hash = 0;
86
87         hash += (id != null ? id.hashCode()
88                             : 0);
89         return hash;
90     }
91
92     @Override JavaDoc
93     public boolean equals(Object JavaDoc object) {
94         if (!(object instanceof Method)) {
95             return false;
96         }
97         Method other = (Method) object;
98
99         if (this.id != other.id &&
100             (this.id == null || !this.id.equals(other.id)))
101             return false;
102         return true;
103     }
104
105     @Override JavaDoc
106     public String JavaDoc toString() {
107         return "test.Method[id=" + id + "]";
108     }
109
110 }
111
Popular Tags