I have a table with two columns user_id
and role_id
. There's no unique column in table and I can't add one. How can I create Entity
and Repository
in Spring without a primary key?
This is my UserRole.class
public class UserRole {
@Column(name = "user_id")
private int userId;
@Column(name = "role_id")
private int roleId;
//getters and setters
}
But with this class i get the following error:
nested exception is org.hibernate.AnnotationException: No identifier specified for entity:
I saw that one of the answers is to use all of the columns as the id, but i have no idea how to do it.