You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.0 KiB

/*
* 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 net.mydreamy.auth.entity;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
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 lp
*/
@Entity
@Table(name = "role")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r")
, @NamedQuery(name = "Role.findById", query = "SELECT r FROM Role r WHERE r.id = :id")
, @NamedQuery(name = "Role.findByName", query = "SELECT r FROM Role r WHERE r.name = :name")})
public class Role implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private Collection<Querytorole> querytoroleCollection;
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private Integer id;
@Size(max = 255)
@Column(name = "NAME")
private String name;
@OneToMany(mappedBy = "role")
private Collection<User> userCollection;
public Role() {
}
public Role(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlTransient
public Collection<User> getUserCollection() {
return userCollection;
}
public void setUserCollection(Collection<User> userCollection) {
this.userCollection = userCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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 Role)) {
return false;
}
Role other = (Role) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "net.mydreamy.auth.Role[ id=" + id + " ]";
}
@XmlTransient
public Collection<Querytorole> getQuerytoroleCollection() {
return querytoroleCollection;
}
public void setQuerytoroleCollection(Collection<Querytorole> querytoroleCollection) {
this.querytoroleCollection = querytoroleCollection;
}
}