2 * Copyright 2005-2010 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.security.authentication;
18 import java.io.Serializable;
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.GenerationType;
24 import javax.persistence.Id;
25 import javax.persistence.NamedQueries;
26 import javax.persistence.NamedQuery;
27 import javax.persistence.Table;
28 import javax.persistence.Version;
33 * @author Erik Brakkee
36 @Table(name = "SEC_GROUP")
38 @NamedQuery(name = Group.QUERY_FIND_BY_NAME, query = "select g from Group g where g.name = :" +
40 @NamedQuery(name = Group.QUERY_COUNT_GROUPS, query = "select count(g) from Group g"),
41 @NamedQuery(name = Group.QUERY_ALL_GROUPS, query = "select g from Group g") })
42 public class Group implements Serializable, Comparable {
44 public static final String QUERY_FIND_BY_NAME = "Group.findByName";
45 public static final String QUERY_COUNT_GROUPS = "Group.count";
46 public static final String QUERY_ALL_GROUPS = "Group.all";
47 public static final String NAME_PARAM = "name";
50 @GeneratedValue(strategy = GenerationType.AUTO)
59 @Column(nullable = false, unique = true)
63 * Constructs the group.
73 * Creates a new Group object.
76 public Group(Group aGroup) {
78 version = aGroup.version;
83 * Creates a new Group object.
91 * Gets the name of the group.
95 public String getName() {
100 * Sets the group name.
105 void setName(String aName) {
112 * @see java.lang.Object#equals(java.lang.Object)
115 public boolean equals(Object aGroup) {
116 if (aGroup == null) {
119 if (!(aGroup instanceof Group)) {
123 return name.equals(((Group) aGroup).name);
129 * @see java.lang.Object#hashCode()
132 public int hashCode() {
133 return name.hashCode();
139 * @see java.lang.Comparable#compareTo(T)
141 public int compareTo(Object aGroup) {
142 return name.compareTo(((Group) aGroup).name);
145 public Long getPrimaryKey() {
149 public void setPrimaryKey(Long aKey) {
156 * @see java.lang.Object#toString()
159 public String toString() {
160 return "Group(pk = " + getPrimaryKey() + ", name=" + name + ")";