I have a two tables which are USER entity have
@OneToMany
@JoinTable(name="user_roles")
private List<Role> roles;
Role Entity have User
@ManyToOne
private User user;
Desc of table user_role is
Name Null
USER_RECORD_ID NOT NULL NUMBER(19)
ROLE_RECORD_ID NOT NULL NUMBER(19)
NOTE: A user can have multiple roles,and i have already created roles through script,have Id:10001,10002,10003 etc
In user_role role table i am inserting one user 800001 with all the roles so the table looks like
USER_RECORD_ID ROLE_RECORD_ID
800001 10001
800001 10002
800001 10003
800002 10001 ///This record will through me unique constraint error
So if i try to give a role to new user where role is predefined it throughs me this error
INSERT INTO USER_ROLE(USER_RECORD_ID,ROLE_RECORD_ID) VALUES(800002,10001)
Error report - SQL Error: ORA-00001: unique constraint (SYSTEM.UK_LPLHY51JOJA1LP4465QK2E0AF) violated 00001. 00000 - "unique constraint (%s.%s) violated" *Cause: An UPDATE or INSERT statement attempted to insert a duplicate key. For Trusted Oracle configured in DBMS MAC mode, you may see this message if a duplicate entry exists at a different level. *Action: Either remove the unique restriction or do not insert the key.