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.usermgt;
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.UniqueConstraint;
29 import javax.persistence.Version;
31 import org.wamblee.security.AbstractPersistent;
36 * @author Erik Brakkee
39 @Table(name = "SEC_GROUP")
41 @NamedQuery(name = Group.QUERY_FIND_BY_NAME, query = "select g from Group g where g.name = :" +
43 @NamedQuery(name = Group.QUERY_COUNT_GROUPS, query = "select count(g) from Group g"),
44 @NamedQuery(name = Group.QUERY_ALL_GROUPS, query = "select g from Group g") })
45 public class Group implements Serializable, Comparable {
47 public static final String QUERY_FIND_BY_NAME = "Group.findByName";
48 public static final String QUERY_COUNT_GROUPS = "Group.count";
49 public static final String QUERY_ALL_GROUPS = "Group.all";
50 public static final String NAME_PARAM = "name";
53 @GeneratedValue(strategy = GenerationType.AUTO)
54 private Long primaryKey;
62 @Column(nullable = false, unique = true)
66 * Constructs the group.
76 * Creates a new Group object.
79 public Group(Group aGroup) {
80 primaryKey = aGroup.primaryKey;
81 version = aGroup.version;
86 * Creates a new Group object.
94 * Gets the name of the group.
98 public String getName() {
103 * Sets the group name.
108 void setName(String aName) {
115 * @see java.lang.Object#equals(java.lang.Object)
118 public boolean equals(Object aGroup) {
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() {
152 * @see java.lang.Object#toString()
155 public String toString() {
156 return "Group(pk = " + getPrimaryKey() + ", name=" + name + ")";