KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How to make it so that the table user_roles defines the two columns (userID, roleID) as a composite primary key. should be easy, just can't remember/find. In user entity: @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "user_roles") public List<RoleDAO> getRoles() { return roles; } @Id @GeneratedValue(strategy = GenerationType.AUTO) public Integer getUserID() { return userID; } In roles entity: @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "user_roles") public List<UserDAO> getUsers() { return users; } @Id @GeneratedValue(strategy = GenerationType.AUTO) public Integer getRoleID() { return roleID; } Thank you. ** MORE INFO So there is a third table user_roles (auto generated by above) that takes userID from user entity and roleID from roles entity. Now I need those two columns in the generated table ( user_roles ) to be a composite primary key.
Tags (comma-separated)
Save Edits
Cancel