View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.model.sweden.impl;
7   
8   import gnu.trove.THashSet;
9   
10  import java.util.Set;
11  
12  import javax.persistence.CascadeType;
13  import javax.persistence.Entity;
14  import javax.persistence.FetchType;
15  import javax.persistence.GeneratedValue;
16  import javax.persistence.GenerationType;
17  import javax.persistence.Id;
18  import javax.persistence.JoinTable;
19  import javax.persistence.OneToMany;
20  import javax.persistence.Table;
21  import javax.persistence.UniqueConstraint;
22  import javax.persistence.Version;
23  
24  import org.hibernate.annotations.Cache;
25  import org.hibernate.annotations.CacheConcurrencyStrategy;
26  
27  import com.hack23.cia.model.core.impl.BaseEntity;
28  
29  /***
30   * The Class Committee.
31   */
32  @Entity
33  @Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "href" }) })
34  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
35  public class Committee extends BaseEntity {
36  
37      /*** The Constant serialVersionUID. */
38      private static final long serialVersionUID = 1L;
39  
40      /*** The href. */
41      private String href;
42  
43      /*** The id. */
44      private Long id;
45  
46      /*** The name. */
47      private String name;
48  
49      /*** The version. */
50      private Long version=1L;
51      
52      /*** The parliament members. */
53      private Set<ParliamentMember> parliamentMembers = new THashSet<ParliamentMember>();
54  
55      /***
56       * Gets the href.
57       *
58       * @return the href
59       */
60      public String getHref() {
61          return href;
62      }
63  
64      /*
65       * (non-Javadoc)
66       * 
67       * @see com.hack23.cia.model.core.BaseEntity#getId()
68       */
69      @Override
70      @Id
71      @GeneratedValue(strategy = GenerationType.AUTO)
72      public Long getId() {
73          return id;
74      }
75  
76      /***
77       * Gets the name.
78       *
79       * @return the name
80       */
81      public String getName() {
82          return name;
83      }
84  
85      /* (non-Javadoc)
86       * @see com.hack23.cia.model.core.BaseEntity#getVersion()
87       */
88      @Override
89      @Version
90      public Long getVersion() {
91          return version;
92      }
93  
94  
95      /***
96       * Sets the href.
97       *
98       * @param href the new href
99       */
100     public void setHref(final String href) {
101         this.href = href;
102     }
103 
104     /***
105      * Sets the id.
106      *
107      * @param id the new id
108      */
109     public void setId(final Long id) {
110         this.id = id;
111     }
112 
113     /***
114      * Sets the name.
115      *
116      * @param name the new name
117      */
118     public void setName(final String name) {
119         this.name = name;
120     }
121 
122     /***
123      * Sets the version.
124      *
125      * @param version the new version
126      */
127     public void setVersion(final Long version) {
128         this.version = version;
129     }
130 
131     /***
132      * Gets the parliament members.
133      *
134      * @return the parliament members
135      */
136     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
137     @JoinTable(name = "CommitteeParliamentMembers")
138 	public Set<ParliamentMember> getParliamentMembers() {
139 		return parliamentMembers;
140 	}
141 
142 	/***
143 	 * Sets the parliament members.
144 	 *
145 	 * @param parliamentMembers the new parliament members
146 	 */
147 	public void setParliamentMembers(final Set<ParliamentMember> parliamentMembers) {
148 		this.parliamentMembers = parliamentMembers;
149 	}
150 
151 }