Answer the question
In order to leave comments, you need to log in
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;
}
}
@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" : {
"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
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question