I have 2 tables. The second table contains two FK to the first one (the meaning is that user can have a team of other users).
CREATE TABLE "user" (
usr_id INTEGER PRIMARY KEY,
usr_login VARCHAR NOT NULL UNIQUE,
);
CREATE TABLE user_team (
utm_id INTEGER PRIMARY KEY,
usr_id INTEGER NOT NULL UNIQUE,
manager_id INTEGER NOT NULL,
CONSTRAINT utm_usr_fk FOREIGN KEY (usr_id)
REFERENCES "user" (usr_id) ON DELETE CASCADE,
CONSTRAINT utm_manager_fk FOREIGN KEY (manager_id)
REFERENCES "user" (usr_id) ON DELETE CASCADE
);
Can I write some annotation mapping in User class to have set of users (team)? For example:
@Entity
@Table(name = "user")
public class User implements Serializable {
@OneToMany ??????????????????????
private List<User> team;
}