/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.pepe.jpa.entities; import java.io.Serializable; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author Junior Cabal */ @Entity @Table(name = "rol") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Rol.findAll", query = "SELECT r FROM Rol r"), @NamedQuery(name = "Rol.findByIdRol", query = "SELECT r FROM Rol r WHERE r.idRol = :idRol"), @NamedQuery(name = "Rol.findByNombreRol", query = "SELECT r FROM Rol r WHERE r.nombreRol = :nombreRol"), @NamedQuery(name = "Rol.findByCodigoRol", query = "SELECT r FROM Rol r WHERE r.codigoRol = :codigoRol")}) public class Rol implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id_rol") private Integer idRol; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "nombre_rol") private String nombreRol; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "codigo_rol") private String codigoRol; @ManyToMany (mappedBy = "rolList") private List<Usuario> usuarioList; public Rol() { } public Rol(Integer idRol) { this.idRol = idRol; } public Rol(Integer idRol, String nombreRol, String codigoRol) { this.idRol = idRol; this.nombreRol = nombreRol; this.codigoRol = codigoRol; } public Integer getIdRol() { return idRol; } public void setIdRol(Integer idRol) { this.idRol = idRol; } public String getNombreRol() { return nombreRol; } public void setNombreRol(String nombreRol) { this.nombreRol = nombreRol; } public String getCodigoRol() { return codigoRol; } public void setCodigoRol(String codigoRol) { this.codigoRol = codigoRol; } @XmlTransient public List<Usuario> getUsuarioList() { return usuarioList; } public void setUsuarioList(List<Usuario> usuarioList) { this.usuarioList = usuarioList; } @Override public int hashCode() { int hash = 0; hash += (idRol != null ? idRol.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 Rol)) { return false; } Rol other = (Rol) object; if ((this.idRol == null && other.idRol != null) || (this.idRol != null && !this.idRol.equals(other.idRol))) { return false; } return true; } @Override public String toString() { return "com.pepe.jpa.entities.Rol[ idRol=" + idRol + " ]"; } }