View Javadoc

1   /*
2    * Copyright 2007 The International Moth Class Association (IMCA)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.imca.model.entities;
17  
18  import java.util.Collection;
19  import javax.persistence.Entity;
20  import javax.persistence.GeneratedValue;
21  import javax.persistence.GenerationType;
22  import javax.persistence.Id;
23  import javax.persistence.NamedQueries;
24  import javax.persistence.NamedQuery;
25  import javax.persistence.ManyToMany;
26  
27  /**
28   * An persistence entity description. There is no logic just getter and setters,
29   * for the properties. This Object represents a table in the database and the
30   * properties are fields.
31   *
32   * @author dougculnane
33   */
34  @Entity
35  @NamedQueries( { 
36      @NamedQuery(name = "findDesignByName",
37              query = "SELECT d FROM DesignEntity d WHERE d.name = :name"),
38      @NamedQuery(name = "DesignBasicSearch",
39              query = "SELECT d FROM DesignEntity d WHERE d.name LIKE :search")
40  })
41  public class DesignEntity {
42  
43      /**
44       * Object Identifier.
45       */
46      @Id
47      @GeneratedValue(strategy=GenerationType.TABLE)
48      private long id;
49  
50      private int year;
51  
52      private String name = "";
53  
54      @ManyToMany
55      private Collection<PersonEntity> designers;
56  
57      private String description = "";
58  
59      public String getDescription() {
60          return description;
61      }
62  
63      public void setDescription(String description) {
64          this.description = description;
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 int getYear() {
76          return year;
77      }
78  
79      public void setYear(int year) {
80          this.year = year;
81      }
82  
83      public long getId() {
84          return id;
85      }
86  
87      public void setId(long id) {
88          this.id = id;
89      }
90  
91      public Collection<PersonEntity> getDesigners() {
92          return designers;
93      }
94  
95      public void setDesigners(Collection<PersonEntity> designers) {
96          this.designers = designers;
97      }
98  
99      /**
100      * Override the Object method to give a usable human readable 
101      * representation of the Object.
102      */
103     public String toString(){
104         return name;
105     }
106 
107 }