【发布时间】:2019-07-15 03:00:26
【问题描述】:
我对 oneToMany 的关系有疑问。我在 SQLite DB 中创建了表,这是我的表:
我的类别模型:
@Entity
@Table(name = "Category")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class CategoryModel {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String category_name;
private String category_description;
private String image_path;
@JsonIgnore
@OneToMany( mappedBy = "category")
private Set<ProductModel> category;
我的产品类别:
@Entity
@Table(name = "Product_Category")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class ProductModel {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long product_id;
private Long category_id;
private String name;
private String description;
private int numberOfProduct;
private String image;
private int price;
@ManyToOne
@JoinColumn(name = "country_id", nullable = false)
private CategoryModel category;
我可以很好地从Category 表中获取数据,但是当我从 Product_Category 表中调用数据时出现错误:
SQL error or missing database (no such column: productmod0_.country_id)
【问题讨论】:
标签: spring-boot sqlite spring-data-jpa