
com.linkare.commons.jpa.security.Group Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa.security Show documentation
Show all versions of jpa.security Show documentation
Project containing the base domain model for security concerns in JPA projects.
The newest version!
package com.linkare.commons.jpa.security;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import org.hibernate.envers.Audited;
import com.linkare.commons.utils.EqualityUtils;
/**
*
* @author Paulo Zenida - Linkare TI
*
*/
@Entity
@NamedQueries({ @NamedQuery(name = Group.FIND_ALL_QUERYNAME, query = Group.FIND_ALL_QUERY),
@NamedQuery(name = Group.COUNT_ALL_QUERYNAME, query = Group.COUNT_ALL_QUERY),
@NamedQuery(name = Group.FIND_BY_NAME_QUERYNAME, query = Group.FIND_BY_NAME_QUERY) })
@DiscriminatorValue("Group")
@Audited
public class Group extends Principal {
private static final long serialVersionUID = -3940451862595249089L;
public static final String QUERY_PARAM_NAME = "name";
public static final String FIND_ALL_QUERYNAME = "Group.findAll";
public static final String FIND_ALL_QUERY = "Select g from Group g";
public static final String COUNT_ALL_QUERYNAME = "Group.countAll";
public static final String COUNT_ALL_QUERY = "Select count(g) from Group g";
public static final String FIND_BY_NAME_QUERYNAME = "Group.findByName";
public static final String FIND_BY_NAME_QUERY = "Select g from Group g where g.name = :" + Group.QUERY_PARAM_NAME;
@Column(name = "name", insertable = true, updatable = false, nullable = true, unique = true)
private String name;
public Group() {
}
public Group(final String name) {
this();
this.name = name;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
@Override
public boolean isGroup() {
return true;
}
@Override
public boolean equals(final Object other) {
if (!(other instanceof Group)) {
return false;
}
return equalsTo((Group) other);
}
@Override
public int hashCode() {
int result = 14;
result = 29 * result + (getName() != null ? getName().hashCode() : 0);
return result;
}
private boolean equalsTo(final Group other) {
return EqualityUtils.equals(getName(), other.getName());
}
@Override
public String toString() {
return getName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy