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.ManyToMany;
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 = "EventBasicSearch",
38              query = "SELECT o FROM EventEntity o WHERE o.name LIKE :search") 
39  })
40  public class EventEntity {
41  
42      /**
43       * Object Identifier.
44       */
45      @Id
46      @GeneratedValue(strategy=GenerationType.TABLE)
47      private long id;
48  
49      @ManyToMany
50      private Collection<SailingClubEntity> sailingClub;
51  
52      private String name = "";
53  
54      private String location = "";
55  
56      @OneToMany
57      private Collection<EventEntryEntity> entries;
58  
59      public Collection<EventEntryEntity> getEntries() {
60          return entries;
61      }
62  
63      public void setEntries(Collection<EventEntryEntity> entries) {
64          this.entries = entries;
65      }
66  
67      public long getId() {
68          return id;
69      }
70  
71      public void setId(long id) {
72          this.id = id;
73      }
74  
75      public String getLocation() {
76          return location;
77      }
78  
79      public void setLocation(String location) {
80          this.location = location;
81      }
82  
83      public Collection<SailingClubEntity> getSailingClub() {
84          return sailingClub;
85      }
86  
87      public void setSailingClub(Collection<SailingClubEntity> sailingClub) {
88          this.sailingClub = sailingClub;
89      }
90  
91      public String getName() {
92          return name;
93      }
94  
95      public void setName(String name) {
96          this.name = name;
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 }