title: JPA Repository :Delete a row from database using native query
body: <p>I want to delete a record on the basis of userId But when I run this code and execute following query it gives me an error on 404 
  Please Help How can I delete Data?</p>
  
  <p><strong>PropertyReport.java</strong></p>
  
  <pre><code>@Entity 
  @Table(uniqueConstraints={
          @UniqueConstraint(columnNames = {"reportedProperty", "reporter"})
      })
  public class PropertyReport implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @OneToOne (cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, targetEntity = Property.class)
      @JoinColumn(name="reportedProperty")
      private Property property;
  
      @OneToOne
      @JoinColumn(name="reporter")
      private User user;
  
      @Column(length=1024)
      private String Report;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public Property getProperty() {
          return property;
      }
  
      public void setProperty(Property property) {
          this.property = property;
      }
  
      public User getUser() {
          return user;
      }
  
      public void setUser(User user) {
          this.user = user;
      }
  
      public String getReport() {
          return Report;
      }
  
      public void setReport(String report) {
          Report = report;
      }
  }
  </code></pre>
  
  <p><strong>PropertyReportReppository.java</strong></p>
  
  <pre><code>public interface PropertyReportRepository extends JpaRepository&lt;PropertyReport, Long&gt;{
  @Modifying
      @PreAuthorize("hasAuthority('allRights')")
      @Query("delete from  PropertyReport pr where pr.user.id=:userId")
      int deleteTenantReview(@Param ("userId") Long userId); }
  </code></pre>
  
  <p>API which I called </p>
  
  <p><strong>API :</strong> <a href="http://localhost:8555/api/propertyReports/search/removeByUserId/2" rel="nofollow noreferrer">http://localhost:8555/api/propertyReports/search/removeByUserId/2</a></p>