I have a Class Site that represents a website and a Class User. A Site can have multiple Users.
class Site {
private int site_ID;
@OneToMany // with a join table
private List<User> users;
// ...
}
class User {
private int user_ID;
private String name;
private String lastname;
private String username;
private String password;
}
I want to allow same username to exist on all Sites, but only one by site.
Site/User/username
1 /1 /username1
1 /2 /username2
2 /3 /username1
How can I do that?
Let the user have a
Sitereference:Now add the constraint to user:
You will also have to change the
Sitemapping: