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  
20  import javax.persistence.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.GenerationType;
23  import javax.persistence.Id;
24  import javax.persistence.ManyToMany;
25  import javax.persistence.NamedQueries;
26  import javax.persistence.NamedQuery;
27  
28  /**
29   * An persistence entity description. There is no logic just getter and setters,
30   * for the properties. This Object represents a table in the database and the
31   * properties are fields.
32   *
33   * @author dougculnane
34   */
35  @Entity
36  @NamedQueries( {
37      @NamedQuery(name = "findSailNumberBySailNumber",
38              query = "SELECT s FROM SailNumberEntity s WHERE " +
39              		"s.sailNumber = :sailNumber"),
40      @NamedQuery(name = "SailNumberBasicSearch",
41              query="SELECT s FROM SailNumberEntity s WHERE " +
42              		"s.sailNumber = :search")
43  })
44  public class SailNumberEntity {
45  
46      /**
47       * Object Identifier.
48       */
49      @Id
50      @GeneratedValue(strategy=GenerationType.TABLE)
51      private long id;
52  
53      private String sailNumber = "";
54  
55      @ManyToMany
56      private Collection<BoatEntity> boats;
57  
58      public long getId() {
59          return id;
60      }
61  
62      public void setId(long id) {
63          this.id = id;
64      }
65  
66      public String getSailNumber() {
67          return sailNumber;
68      }
69      
70      public void setSailNumber(String sailNumber) {
71          this.sailNumber = sailNumber;
72      }
73  
74      public Collection<BoatEntity> getBoats() {
75          return boats;
76      }
77  
78      public void setBoats(Collection<BoatEntity> boats) {
79          this.boats = boats;
80      }
81  
82      /**
83       * Override the Object method to give a usable human readable 
84       * representation of the Object.
85       */
86      public String toString(){
87          return sailNumber;
88      }
89  }