package com.acme.model.domain.ejf.entity;


import com.acme.structure.BaseEntity;
import com.acme.structure.BaseEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


@Entity(name = "RoleGroupDetail")
@Table(name = "MAINROLEGROUPDETS")
//this is for oracle db @SequenceGenerator(name = "ROLEGROUPDET_SEQ", sequenceName = "ROLEGROUPDET_SEQ", allocationSize = 1)
@EntityListeners( { BaseEntityListener.class })
public class RoleGroupDetail extends BaseEntity
{
    private Role role;

    public RoleGroupDetail()
    {
        entityName = "RoleGroupDetail";
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) //, this is for oracle db, generator = "ROLEGROUPDET_SEQ")
    @Column(name = "ID")
    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    @ManyToOne(targetEntity = Role.class, cascade = { })
    @JoinColumn(name = "ROLEID")
    public Role getRole()
    {
        return role;
    }

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

    @Override
    public String toString()
    {
        return getId() + "-" + getRole().toString();
    }

}
