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.OneToMany;
19  import javax.persistence.Version;
20  
21  import org.hibernate.annotations.Cache;
22  import org.hibernate.annotations.CacheConcurrencyStrategy;
23  
24  import com.hack23.cia.model.core.impl.BaseEntity;
25  
26  /***
27   * The Class PoliticalParty.
28   */
29  @Entity
30  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
31  public class PoliticalParty extends BaseEntity {
32  
33      /*** The Constant serialVersionUID. */
34      private static final long serialVersionUID = 1L;
35  
36  
37      /*** The id. */
38      private Long id;
39  
40      /*** The name. */
41      private String name;
42  
43      /*** The parliament members. */
44      private Set<ParliamentMember> parliamentMembers = new THashSet<ParliamentMember>();
45      
46      /*** The short code. */
47      private String shortCode;
48      
49      /*** The version. */
50      private Long version=1L;
51      
52      /***
53       * Instantiates a new political party.
54       */
55  	public PoliticalParty() {
56  		super();
57  	}
58  
59      /*
60       * (non-Javadoc)
61       * 
62       * @see com.hack23.cia.model.core.BaseEntity#getId()
63       */
64      @Override
65      @Id
66      @GeneratedValue(strategy = GenerationType.AUTO)
67      public Long getId() {
68          return id;
69      }
70  
71      /***
72       * Gets the name.
73       *
74       * @return the name
75       */
76  	public String getName() {
77  		return name;
78  	}
79  
80  
81      /***
82       * Gets the parliament members.
83       *
84       * @return the parliament members
85       */
86      @OneToMany(mappedBy = "politicalParty", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
87      @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
88  	public Set<ParliamentMember> getParliamentMembers() {
89  		return parliamentMembers;
90  	}
91  
92  	/***
93  	 * Gets the short code.
94  	 *
95  	 * @return the short code
96  	 */
97  	public String getShortCode() {
98  		return shortCode;
99  	}
100 
101 	/* (non-Javadoc)
102      * @see com.hack23.cia.model.core.BaseEntity#getVersion()
103      */
104     @Override
105     @Version
106     public Long getVersion() {
107         return version;
108     }
109 
110 	/***
111 	 * Sets the id.
112 	 *
113 	 * @param id the new id
114 	 */
115     public void setId(final Long id) {
116         this.id = id;
117     }
118 
119 	/***
120 	 * Sets the name.
121 	 *
122 	 * @param name the new name
123 	 */
124 	public void setName(final String name) {
125 		this.name = name;
126 	}
127 
128 	/***
129 	 * Sets the parliament members.
130 	 *
131 	 * @param parliamentMembers the new parliament members
132 	 */
133 	public void setParliamentMembers(final Set<ParliamentMember> parliamentMembers) {
134 		this.parliamentMembers = parliamentMembers;
135 	}
136 
137     /***
138      * Sets the short code.
139      *
140      * @param shortCode the new short code
141      */
142 	public void setShortCode(final String shortCode) {
143 		this.shortCode = shortCode;
144 	}
145 
146 	/***
147 	 * Sets the version.
148 	 *
149 	 * @param version the new version
150 	 */
151     public void setVersion(final Long version) {
152         this.version = version;
153     }
154 
155 
156 }