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 = "UserRoleGroup")
@Table(name = "MAINUSERROLEGROUPS")
//this is for oracle db @SequenceGenerator(name = "USERROLEGROUP_SEQ", sequenceName = "USERROLEGROUP_SEQ", allocationSize = 1)
@EntityListeners( { BaseEntityListener.class })
public class UserRoleGroup extends BaseEntity
{
    private RoleGroup roleGroup;

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

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

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

    @ManyToOne(targetEntity = RoleGroup.class, cascade = { })
    @JoinColumn(name = "ROLEGROUPID")
    public RoleGroup getRoleGroup()
    {
        return roleGroup;
    }

    public void setRoleGroup(RoleGroup roleGroup)
    {
        this.roleGroup = roleGroup;
    }

    @Override
    public String toString()
    {
        return "Mapping to " + roleGroup.getName();
    }

}
