I meet a difficult in the following problems... In my project, there are 4 tables: user, role, permission, and role_permission The following are the details of these 4 tables: user ----- UserName varchar(10), primary key RoleID int role ----- RoleID int, primary key RoleName varchar(30) permission ----------- PermissionID int, primary key PermissionName varchar(30) role_permission ---------------- RoleID int, primary key PermissionID int, primary key Each user should have a RoleID. In the table role_permission, it is used to store which role can access the permission page. Because each role can have the access more than one page, RoleID and PermissionID are the primary key. Now, I want to get which PermissionName can have access for a specified user. How should I create this relationship? Moreover, which entity beans should I create? Thanks! Stephen Lee
Hi, Stephen: I think you can create three CMP, RoleBean, UserBean and PermissionBean. R and U have an one- to-many relationship, you user roleID in the U table to map the relationship. R and P have a many-to-many relationship, you can user R-P table to map this relationship. In my opinion, you don't need to define any primary key in the R-P table. To get the permissions of a user, you use UserLocal.getRole().getPermissions() to get a Collection of permissions the user has. Good Luck. Frank
subject: How to create Entity bean relationship for this?