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.OneToMany;
26  import javax.persistence.ManyToOne;
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 = "BoatVersionSearch",
38              query = "SELECT o FROM BoatVersionEntity o WHERE o.id LIKE :search"),
39      @NamedQuery(name = "BoatVersionBasicSearch",
40              query = "SELECT o FROM BoatVersionEntity o WHERE o.description LIKE :search")
41  })
42  public class BoatVersionEntity {
43  
44      /**
45       * Object Identifier.
46       */
47      @Id
48      @GeneratedValue(strategy=GenerationType.TABLE)
49      private long id;
50  
51      /**
52       * Long description of the boat.
53       */
54      private String description = "";
55      
56      @ManyToOne
57      private BoatEntity boat;
58  
59      @OneToMany
60      private Collection<SailEntity> sails;
61  
62      @OneToMany
63      private Collection<FoilEntity> foils;
64  
65      @OneToMany
66      private Collection<MastEntity> masts;
67  
68      public BoatEntity getBoat() {
69          return boat;
70      }
71  
72      public void setBoat(BoatEntity boat) {
73          this.boat = boat;
74      }
75  
76      public long getId() {
77          return id;
78      }
79  
80      public void setId(long id) {
81          this.id = id;
82      }
83  
84      public Collection<FoilEntity> getFoils() {
85          return foils;
86      }
87  
88      public void setFoils(Collection<FoilEntity> foils) {
89          this.foils = foils;
90      }
91  
92      public Collection<MastEntity> getMasts() {
93          return masts;
94      }
95  
96      public void setMasts(Collection<MastEntity> masts) {
97          this.masts = masts;
98      }
99  
100     public Collection<SailEntity> getSails() {
101         return sails;
102     }
103 
104     public void setSails(Collection<SailEntity> sails) {
105         this.sails = sails;
106     }
107 
108     /**
109      * Override the Object method to give a usable human readable 
110      * representation of the Object.
111      */    
112     public String toString(){
113         return id + "";
114     }
115 
116     public String getDescription() {
117         return description;
118     }
119 
120     public void setDescription(String description) {
121         this.description = description;
122     }
123 
124 }