I'm using Spring Data Rest and I have an Entity employee
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;
@Column(name = "first_Name")
@com.luv2code.springboot.demo.BootDataRest2.Validators.Employee
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "email")
@NotBlank(message = "Email is mandatory")
@Email()
private String email;}
and trying to delete by firstName by extending JpaRepository as follows.
@RepositoryRestResource( collectionResourceRel = "employees")
public interface EmployeeRepository extends JpaRepository\<Employee,Integer\> {
@Modifying
@Transactional
public int deleteByFirstName(String firstName);
@Query(value = "SELECT e FROM Employee e where e.firstName like %?1% or e.lastName like %?1%")
public List<Employee> searchWithAny(String searchText);
}
The code works only if I identified the method type in postman as GET, If selected method type as DELETE I get 404 NOT FOUND.
I dont know whether it is the default spring data behavior or I'm missing something.
Adding that the URL is available under the search resource "http://localhost:8888/employees/search/deleteByFirstName%7B?firstName}"