【发布时间】:2020-02-21 06:10:42
【问题描述】:
使用邮递员发布数据或运行程序时,遇到以下错误:
无法找到 id 为 1 的 com.example.entity.Product;嵌套异常是 javax.persistence.EntityNotFoundException: Unable to find com.example.entity.Product with id 1
下面是父类:
@Entity
public class Customer {
@Id
@GeneratedValue
private Integer cust_Id;
private String cust_name;
private String city;
@OneToMany(mappedBy = "customer")
private List<Product> products;
}
Child class:
@Entity
public class Product {
@Id
private Integer pid;
private String pname;
@ManyToOne(fetch = FetchType.LAZY)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "fk_cust_id")
private Customer customer;
}
【问题讨论】:
-
你用的是什么休眠版本?
-
Spring boot with data-jpa, Spring boot-2.0.1.RELEASE
标签: spring hibernate spring-boot spring-data