RoleInheritance.java 2.8 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fi.insomnia.bortal.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * 
 * @author jkj
 */
@Entity
@Table(name = "role_inheritance", uniqueConstraints = { @UniqueConstraint(columnNames = {
	"roles_id", "inherits" }) })
@NamedQueries( {
	@NamedQuery(name = "RoleInheritance.findAll", query = "SELECT r FROM RoleInheritance r"),
	@NamedQuery(name = "RoleInheritance.findByRoleInheritanceId", query = "SELECT r FROM RoleInheritance r WHERE r.roleInheritanceId = :roleInheritanceId") })
public class RoleInheritance implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "role_inheritance_id", nullable = false)
    private Integer roleInheritanceId;
    @JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false)
    @ManyToOne(optional = false)
    private Role rolesId;
    @JoinColumn(name = "inherits", referencedColumnName = "roles_id", nullable = false)
    @ManyToOne(optional = false)
    private Role inherits;

    public RoleInheritance() {
    }

    public RoleInheritance(Integer roleInheritanceId) {
	this.roleInheritanceId = roleInheritanceId;
    }

    public Integer getRoleInheritanceId() {
	return roleInheritanceId;
    }

    public void setRoleInheritanceId(Integer roleInheritanceId) {
	this.roleInheritanceId = roleInheritanceId;
    }

    public Role getRolesId() {
	return rolesId;
    }

    public void setRolesId(Role rolesId) {
	this.rolesId = rolesId;
    }

    public Role getInherits() {
	return inherits;
    }

    public void setInherits(Role inherits) {
	this.inherits = inherits;
    }

    @Override
    public int hashCode() {
	int hash = 0;
	hash += (roleInheritanceId != null ? roleInheritanceId.hashCode() : 0);
	return hash;
    }

    @Override
    public boolean equals(Object object) {
	// TODO: Warning - this method won't work in the case the id fields are
	// not set
	if (!(object instanceof RoleInheritance)) {
	    return false;
	}
	RoleInheritance other = (RoleInheritance) object;
	if ((this.roleInheritanceId == null && other.roleInheritanceId != null)
		|| (this.roleInheritanceId != null && !this.roleInheritanceId
			.equals(other.roleInheritanceId))) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "fi.insomnia.bortal.model.RoleInheritance[roleInheritanceId="
		+ roleInheritanceId + "]";
    }

}