Thanks for your help !
The roll class :
Code:
@Entity
@Table(uniqueConstraints={@UniqueConstraint(columnNames={"name"})})
public final class Role {
@Id
@GeneratedValue
private String id;
private String name = null;
private String description = null;
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="ROLE_ACCESSRIGHT", joinColumns = @JoinColumn(name="ROLE_ID"), inverseJoinColumns = @JoinColumn( name="ACCESSRIGHTS_ID"))
@org.hibernate.annotations.MapKey(columns = @Column(name="AppModule"))
@Enumerated(value=EnumType.STRING)
private Map<MenuEnum, AccessRight> accessRights = null;
}
The AccessRight class :
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class AccessRight {
@Id
@GeneratedValue
private String id;
@Column(name = "AR_READ")
private boolean read = false;
@Column(name = "AR_CREATION")
private boolean creation = false;
@Column(name = "AR_UPDATE")
private boolean update = false;
@Column(name = "AR_DELETE")
private boolean delete = false;
}
The MenuEnum enum :
Code:
public enum MenuEnum
{
DT (0 , "di" , "demande_de_travaux"),
PLANIFICATION (1 , "plan" , "planification"),
GAMMESYSTEMATIQUE (2 , "gsp" , "SY"),
PLANMAINTENANCE (3 , "pmp" , "PM"),
PREVENTIVECR (4 , "pcr" , "CR"),
DONNEESTECHNIQUES (5 , "dt" , "donnee_technique"),
STOCK (6 , "stock" , "stock"),
STATISTIQUES (7 , "stat" , "statistiques"),
HISTORIQUE (8 , "histo" , "historique"),
GESTION (10 , "gestion" , "gestion"),
PARAMETRAGE (9 , "param" , "parametrage");
private int numero;
private String id;
private String title;
MenuEnum(int numero , String id , String title)
{
this.numero = numero;
this.id = id;
this.title = title;
}
}
(I have removed the getter/setter)