hibernate: ternary association mapping

后端 未结 1 1301
渐次进展
渐次进展 2021-01-16 06:16

Technology Description: Hibernate annotation- 3.4.0.GA java 1.5

table : users_roles_branches columns : user_id, role_id, branch_id<

相关标签:
1条回答
  • 2021-01-16 07:06

    My suggestion would be to introduce a new concept in your domain-model RoleAssignment:

    class RoleAssignment {
      private User user; 
      private Branch branch;
      private Role role;
    }
    

    Entities User, Branch and Role should have 1:N relationship with RoleAssignment. For eg:

    class User { 
      private Set<RoleAssignment> roleAssignemnts;
    }
    
    0 讨论(0)
提交回复
热议问题