Spring Boot methods to add and remove relationships
You may extract the action part as a method parameter (I am using BiConsumer in this case).

@Override
public void performActionOnRecords(Long personRecordId, AssociationDTO associationDTO, BiConsumer&lt;PersonRecord,Document&gt; action) {
    PersonRecord personRecord = personRecordRepository.findById(personRecordId).orElse(null);
    if (personRecord == null)
        return;

    for (Long documentId : associationDTO.getDocumentsId())
        documentRepository
                .findById(documentId)
                .ifPresent(document -&gt; action.accept(personRecord,document));

    personRecordRepository.save(personRecord);
}


and call the methods as  

performActionOnRecords(personId, associationDTO, (personRecord, document) -&gt; personRecord.getDocuments().add(document)); // To add document


and,

performActionOnRecords(personId, associationDTO, (personRecord, document) -&gt; personRecord.getDocuments().remove(document)); // To remove document