1 19 package org.netbeans.modules.exceptions.entity; 20 21 import java.io.Serializable ; 22 import java.util.Collection ; 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 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 { 41 42 43 @Id 44 @Column(name = "ID", nullable = false) 45 private Integer id; 46 @Column(name = "NAME") 47 private String name; 48 @OneToMany(cascade = CascadeType.ALL, mappedBy = "method") 49 private Collection <Line> lineCollection; 50 51 52 public Method() { 53 } 54 55 public Method(Integer id) { 56 this.id = id; 57 } 58 59 public Integer getId() { 60 return id; 61 } 62 63 public void setId(Integer id) { 64 this.id = id; 65 } 66 67 public String getName() { 68 return name; 69 } 70 71 public void setName(String name) { 72 this.name = name; 73 } 74 75 public Collection <Line> getLineCollection() { 76 return lineCollection; 77 } 78 79 public void setLineCollection(Collection <Line> lineCollection) { 80 this.lineCollection = lineCollection; 81 } 82 83 @Override 84 public int hashCode() { 85 int hash = 0; 86 87 hash += (id != null ? id.hashCode() 88 : 0); 89 return hash; 90 } 91 92 @Override 93 public boolean equals(Object 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 106 public String toString() { 107 return "test.Method[id=" + id + "]"; 108 } 109 110 } 111 | Popular Tags |