I have many to many relation between user to role
USER ENTITY:
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import
try saving the role also, you haven't stored the role after changing it in addrole function in user entity.
UserRole attributes aren’t the table’s primary ID so @Id should not be on these 2.
You should add an ID attribute to UserRole and annotate that with @Id and @GeneratedValue.
The @ManyToOne will result in a foreign key in the database