At first add @JoinColumn(name = "user_id") for user property,then instead of trying to set the Doctor's ID directly, retrieve the User entity first and then set it in the Doctor object before saving it.