I have requirement where in which i need to override the delete functionality from the rest Resource using a custom controller.here is the code for restResource
@RepositoryRestResource
public interface SampleRepository extends JpaRepository<Sample,Long>{
List<Sample> findBySampleNumber(@Param("sampleNumber") String sampleNumber);
}
i have created a a custom controller which overides only delete fuctionality
@RepositoryRestController
@RequestMapping("/api/samples")
public class SampleController{
@Autowired
SampleRepository sampleRepository;
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseBody
public void delete(@PathVariable Long id) {
//do some custom logic here
//then delete the sample
//sampleRepository.delete(id);
}
However if now try to make a GET api/samples/1(someId)
or look up some search functionality on the RepositoryRestResource, I see the following error
"description": "Request method 'GET' not supported"
is there way to override only one HTTP verb have the rest of the functionality coming up from the repository.
However if i comment public void delete
from the controller i am able to access all the crud and Search operations
Has Anyone encountered such an issue
I am using SPRING_DATA_REST-2.5.1-Release