title: Customize DELETE method in Spring Data repository
body: <p>For some logging purpose, i'm using AspectJ to log CRUD operations, for the delete operation i'm supporting only <code>repository.delete(object)</code> so <code>repository.delete(id)</code> is not supported, but while using http DELETE call in Spring Data repository, i intercept <code>repository.findOne()</code> then <code>repository.delete(id)</code> calls.</p>
  
  <p><strong>My Question</strong></p>
  
  <p>How i could customize Http DELETE method in Spring Data repository to call <code>repository.delete(object)</code> not <code>repository.delete(id)</code>.</p>
  
  <p>here's repository interface:</p>
  
  <pre><code>package com.geopro.repositories;
  
  import org.springframework.data.jpa.repository.Query;
  import org.springframework.data.repository.CrudRepository;
  import org.springframework.data.repository.PagingAndSortingRepository;
  import org.springframework.data.rest.core.annotation.RepositoryRestResource;
  
  import com.geopro.entities.Product;
  
  @RepositoryRestResource(collectionResourceRel = "product", path = "product")
  public interface ProductRepository extends PagingAndSortingRepository&lt;Product, Long&gt; {
  
  }
  </code></pre>
  
  <p>AspectJ code :</p>
  
  <pre><code>@Pointcut("execution(public * org.springframework.data.repository.Repository+.*(..))")
  public void publicNonVoidRepositoryMethod() {
  }
  
  @Around("publicNonVoidRepositoryMethod()")
  public Object publicNonVoidRepositoryMethod(ProceedingJoinPoint pjp) throws Throwable {
  
      if (pjp.getArgs()[0].getClass().getName() == "java.util.Arrays$ArrayList"  || pjp.getArgs()[0].getClass().getName() == "java.util.LinkedList") {
          Iterable arr = (Iterable) pjp.getArgs()[0];
          return saveHistoriqueOperation2(pjp, arr);
      } else {
          Object objs = pjp.getArgs()[0];
          if (objs.getClass().getName() == "com.geopro.entities.HistOperation") {
              Object o = pjp.proceed();
              return o;
          }
          return saveHistoriqueOperation(pjp, objs);
      }
  
  }
  </code></pre>
  
  <p>i'm managing cases where <code>objs</code> is an entity object, so all my delete operations are using <code>delete(entity_object)</code>, not <code>delete(id)</code>, i'm looking for a manner to modify function calls where http DELETE 'ressource_url/id' gets called.</p>
  
  <p>Thanks in advance</p>