
com.linkare.commons.jpa.security.Permission 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.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.envers.AuditTable;
import org.hibernate.envers.Audited;
import com.linkare.commons.jpa.DefaultDomainObject;
import com.linkare.commons.utils.EqualityUtils;
/**
*
* @author Paulo Zenida - Linkare TI
*
*/
@Entity
@Table(name = "permission", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
@NamedQueries({ @NamedQuery(name = Permission.FIND_ALL_QUERYNAME, query = Permission.FIND_ALL_QUERY),
@NamedQuery(name = Permission.COUNT_ALL_QUERYNAME, query = Permission.COUNT_ALL_QUERY) })
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "instance_type")
@DiscriminatorValue("Permission")
@Audited
@AuditTable("permission_audit")
public class Permission extends DefaultDomainObject {
private static final long serialVersionUID = 1L;
public static final String ERROR_NAME_CANNOT_BE_NULL = "error.name.cannot.be.null";
public static final String FIND_ALL_QUERYNAME = "Permission.findAll";
public static final String FIND_ALL_QUERY = "Select p from Permission p";
public static final String COUNT_ALL_QUERYNAME = "Permission.countAll";
public static final String COUNT_ALL_QUERY = "Select count(p) from Permission p";
@Basic(optional = false)
@Column(insertable = true, updatable = false, name = "name", nullable = false)
private String name;
@Basic(optional = true)
@Column(name = "description")
private String description;
@Column(name = "instance_type", insertable = false, updatable = false)
private String instanceType;
public Permission() {
super();
}
public Permission(final String name) {
this();
checkParameters(name);
this.name = name;
}
private void checkParameters(final String name) {
if (name == null) {
throw new IllegalArgumentException(ERROR_NAME_CANNOT_BE_NULL);
}
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the instanceType
*/
public String getInstanceType() {
return instanceType;
}
/**
* @param instanceType
* the instanceType to set
*/
public void setInstanceType(String instanceType) {
this.instanceType = instanceType;
}
@Override
public boolean equals(final Object other) {
if (!(other instanceof Permission)) {
return false;
}
return equalsTo((Permission) other);
}
@Override
public int hashCode() {
int result = 14;
result = 29 * result + (getName() != null ? getName().hashCode() : 0);
return result;
}
private boolean equalsTo(final Permission other) {
return EqualityUtils.equals(getName(), other.getName());
}
@Override
public String toString() {
return getName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy