* 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.
- */
+ */
package org.wamblee.usermgt;
-import org.wamblee.persistence.AbstractPersistent;
-
import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.persistence.Version;
+
+import org.wamblee.security.AbstractPersistent;
+
/**
* Represents a group.
*
* @author Erik Brakkee
*/
-public class Group extends AbstractPersistent implements Serializable,
- Comparable {
+@Entity
+@Table(name = "SEC_GROUP")
+@NamedQueries( {
+ @NamedQuery(name = Group.QUERY_FIND_BY_NAME, query = "select g from Group g where g.name = :" +
+ Group.NAME_PARAM),
+ @NamedQuery(name = Group.QUERY_COUNT_GROUPS, query = "select count(g) from Group g"),
+ @NamedQuery(name = Group.QUERY_ALL_GROUPS, query = "select g from Group g") })
+public class Group implements Serializable, Comparable {
+
+ public static final String QUERY_FIND_BY_NAME = "Group.findByName";
+ public static final String QUERY_COUNT_GROUPS = "Group.count";
+ public static final String QUERY_ALL_GROUPS = "Group.all";
+ public static final String NAME_PARAM = "name";
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long primaryKey;
+
+ @Version
+ private int version;
+
/**
* Group name.
*/
+ @Column(nullable = false, unique = true)
private String name;
/**
*
*/
public Group(Group aGroup) {
- super(aGroup);
name = aGroup.name;
}
public int compareTo(Object aGroup) {
return name.compareTo(((Group) aGroup).name);
}
+
+ public Long getPrimaryKey() {
+ return primaryKey;
+ }
/*
* (non-Javadoc)