P
P
programmerjava2015-10-08 12:05:59
Java
programmerjava, 2015-10-08 12:05:59

Spring boot data rest 404 response?

Greetings. I've been having this issue for an hour and a half now.
There is an essence

@Entity
@Table(name = "checks")
public class Check {
    @GeneratedValue
    @Id
    private Integer id;

    private Date dateTime;

    private String comment;

    private String shopName;

    @OneToMany(mappedBy = "storedCheck", cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    private List<Product> productList;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDateTime() {
        return dateTime;
    }

    public void setDateTime(Date dateTime) {
        this.dateTime = dateTime;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public List<Product> getProductList() {
        return productList;
    }

    public void setProductList(List<Product> productList) {
        this.productList = productList;
    }

}

I will not lay out the Product entity - there are no problems there. you can imagine it yourself.
I have this repository:
@RepositoryRestResource(collectionResourceRel = "checks",path = "checks")
public interface RestCheckRepo
        extends JpaRepository<Check,Integer> {

        public List<Check> findByShopName(@Param("shopName") String shopName);

        public List<Check> findByShopNameAndDateTimeBetween(@Param("shopName") String shop,
                                                            @Param("start")Date start, @Param("end") Date end);
}

Links like localhost:8080/checks/, http://localhost:8080/checks/{id} work well.
The first one gives the following response:
{
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/checks{?page,size,sort}",
      "templated" : true
    }
  },
  "_embedded" : {
    "checks" : [ {
      "dateTime" : null,
      "comment" : null,
      "shopName" : "shop",
      "productList" : [ {
        "name" : "product",
        "price" : null,
        "u" : null,
        "value" : null,
        "discountPercents" : null
      } ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/checks/1"
        },
        "storedCheck" : {
          "href" : "http://localhost:8080/checks/1/storedCheck"
        }
      }
    }, {
      "dateTime" : null,
      "comment" : null,
      "shopName" : "bb",
      "productList" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/checks/2"
        },
        "storedCheck" : {
          "href" : "http://localhost:8080/checks/2/storedCheck"
        }
      }
    } ]
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

But the localhost:8080/checks/search links don't work - the server's response is 404. The body is empty.
I want it to work. Who knows how to help me?
I also emptied the repository from methods - the result is the same

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question