com.melayer.camzia.domain.MeRole.java Source code

Java tutorial

Introduction

Here is the source code for com.melayer.camzia.domain.MeRole.java

Source

/*
 * 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.melayer.camzia.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.springframework.security.core.GrantedAuthority;

/**
 *
 * @author aniruddha
 */
@Entity
@Table(name = "me_role")
public class MeRole implements GrantedAuthority {

    private Long idRole;

    private String role;

    private Set<MeUser> users = new HashSet<>();

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id_role", unique = true, nullable = false)
    public Long getIdRole() {
        return idRole;
    }

    public void setIdRole(Long idRole) {
        this.idRole = idRole;
    }

    @Column(name = "role_name", unique = false, nullable = false)
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @JsonIgnore
    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
    public Set<MeUser> getUsers() {
        return users;
    }

    public void setUsers(Set<MeUser> users) {
        this.users = users;
    }

    @Override
    @Transient
    public String getAuthority() {

        return role;
    }
}