title: Calling another entity's repository from service layer of an entity
body: <p>There are two entities: <strong>Invitation</strong> and <strong>Group</strong></p>
  
  <p>A user can invite another user to a group. I have a controller for the invitation Rest API endpoint and a service layer that implements the business logic. </p>
  
  <p><strong>accept</strong> method is defined in the invitation service layer:</p>
  
  <pre><code>public void accept(long invitationId, String username) {
      Invitation invitation = this.loadById(invitationId);
      User user = userService.loadByUsername(username);
      validateAccessToInvitation(invitation, user);
      Group group = invitation.getGroup();
      group.addMember(user);
      invitationRepository.delete(invitation);
      // groupRepository.save(group);
  }
  </code></pre>
  
  <p>I'd like to know if it is a good idea to access another entity repository (here: <code>group repository</code>) some entity service layer (here: <code>invitation</code> service layer). </p>
  
  <p>One option is to add <code>save</code> method to <code>group</code> service layer. But it would only call the save on the <code>groupRepository</code>, which is somehow feels like it shouldn't be a good design. </p>