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 javax.persistence.Entity;
19  import javax.persistence.GeneratedValue;
20  import javax.persistence.GenerationType;
21  import javax.persistence.Id;
22  import javax.persistence.NamedQueries;
23  import javax.persistence.NamedQuery;
24  import javax.persistence.OneToOne;
25  import javax.persistence.ManyToOne;
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 = "findCommitteeMember",
37              query = "SELECT c FROM CommitteeMemberEntity c WHERE " +
38              		"c.positionName = :positionName " +
39              		"AND c.assosiation = :assosiation"),
40      @NamedQuery(name = "findCommitteeMemberships",
41              query = "SELECT c FROM CommitteeMemberEntity c WHERE " +
42              		"c.person = :person"),
43      @NamedQuery(name = "findAssociationsCommitteeMembers",
44              query = "SELECT c FROM CommitteeMemberEntity c WHERE " +
45                      "c.assosiation.isoCountryCode = :countryCode " +
46                      " AND c.assosiation.area = :area"),
47      @NamedQuery(name = "CommitteeMemberBasicSearch",
48              query = "SELECT c FROM CommitteeMemberEntity c WHERE " +
49              		"c.positionName LIKE :search")
50  })
51  public class CommitteeMemberEntity {
52  
53      /**
54       * Object Identifier.
55       */
56      @Id
57      @GeneratedValue(strategy=GenerationType.TABLE)
58      private long id;
59  
60      private String positionName;
61  
62      @OneToOne
63      private PersonEntity person;
64  
65      @ManyToOne
66      private AssociationEntity assosiation;
67  
68      public long getId() {
69          return id;
70      }
71  
72      public void setId(long id) {
73          this.id = id;
74      }
75  
76      public String getPositionName() {
77          return positionName;
78      }
79  
80      public void setPositionName(String positionName) {
81          this.positionName = positionName;
82      }
83  
84      public PersonEntity getPerson() {
85          return person;
86      }
87  
88      public void setPerson(PersonEntity person) {
89          this.person = person;
90      }
91  
92      public AssociationEntity getAssosiation() {
93          return assosiation;
94      }
95  
96      public void setAssosiation(AssociationEntity assosiation) {
97          this.assosiation = assosiation;
98      }
99  
100     /**
101      * Override the Object method to give a usable human readable 
102      * representation of the Object.
103      */
104     public String toString(){
105         return this.positionName + " - " + this.assosiation.toString();
106     }
107 }