title: Insert after delete same transaction in Spring Data JPA
body: <p>Using Spring Data JPA I have the next flow inside the same transaction (REQUIRES_NEW) :</p>
  
  <ol>
  <li><p>Remove a set of user's predictions with this Spring Data JPA repository method.</p>
  
  <pre><code>@Query(value = "DELETE FROM TRespuestaUsuarioPrediccion resp WHERE resp.idEvento.id = :eventId AND resp.idUsuario.id = :userId")
  @Modifying
  void deleteUserPredictions(@Param("userId") int userId, @Param("eventId") int eventId);
  </code></pre></li>
  <li><p>Insert the new user's predictions and save the master object (event).</p>
  
  <pre><code>eventRepository.save(event);
  </code></pre></li>
  </ol>
  
  <p>When this service finishes, the commit is made by AOP but only works in first attemp...not in the next ones...</p>
  
  <p>How can I manage this situation without iterating over event's predictions entries and updating each one inside?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tried with that and it doesn't work (the adapter inserts the objects I remove before):</p>
  
  <pre><code>@Transactional(propagation=Propagation.REQUIRES_NEW, rollbackFor=PlayTheGuruException.class)
  private void updateUserPredictions(final TUsuario user, final TEvento event, final SubmitParticipationRequestDTO eventParticipationRequestDTO) 
  {
      eventRepository.deleteUserPredictions(user.getId(), event.getId());
      EventAdapter.predictionParticipationDto2Model(user, event, eventParticipationRequestDTO);
      eventRepository.save(event);
  }
  </code></pre>