I have a class User that can have many loginNames:
@Entity
public class User {
@ElementCollection
private List<String> logins = new ArrayList<String>();
}
I want to ensure that each login is unique in the system when a user registers. When someone logs in the user object should be found by the login name. So the elements in the collection are some kind of (database) key.
How can I make them keys? How can I query efficiently? Would it be better to use a separate entity class for the login name?