title: InvalidDataAccessApiUsageException: Unknown entity: UserWithRoles
body: <p>I'm working on a Spring Boot project using spring security, and when I edit the user I get an InvalidDataAccessApiUsageException and a traceback. Below is the full message:</p>
  
  <p>2020-06-04 09:35:58.542 ERROR 13591 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Unknown entity: com.progeny.model.UserWithRoles; nested exception is java.lang.IllegalArgumentException: Unknown entity: com.progeny.model.UserWithRoles] with root cause</p>
  
  <p>Here is the code of the controller:</p>
  
  <pre><code>// --------- ADD FRIEND (POST)------------
  @PostMapping("/profile/friends/edit")
  public String addFriend(@RequestParam long friendId, Model model) {
  
      User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); //1. Get the current user
  
      User friend = usersRepo.getUserById(friendId);
  
      System.out.println(currentUser.getFirstName());
      System.out.println(friend.getFirstName());
  
      if(friend.getFriends() == null){ // if there is no friends list --&gt;
  
          List&lt;User&gt; newFriends = new ArrayList&lt;&gt;(); // 1. Make a new friends list
          friend.setFriends(newFriends); // 2. give the new friends list to User
  
      }
      if(currentUser.getFriends() == null){ // if there is no friends list --&gt;
  
          List&lt;User&gt; newFriends = new ArrayList&lt;&gt;(); // 1. Make a new friends list
          currentUser.setFriends(newFriends); // 2. give the new friends list to User
  
      }
  
      // --------- ADD USER TO FRIEND-----------
      currentUser.getFriends().add(friend);
  
      System.out.println(currentUser.getFriends().get(0).getUsername());
  
      // --------- ADD FRIEND TO USER------------
      friend.getFriends().add(currentUser);
  
      System.out.println(friend.getFriends().get(0).getUsername());
  
      // --------- SAVE TO DB -----------
      usersRepo.save(currentUser); // 3. save the list of users to the current users information
      usersRepo.save(friend); // 3. save the list of users to the current users information
  
      return "users/showConnections";
  }
  </code></pre>
  
  <p>Any help is appreciated.</p>