以下是我的两个相关表格
public class VProduct{
@Id
@Column(name="product_id")
private Long productId;
@OneToMany(mappedBy="vProduct", fetch = FetchType.EAGER, cascade={CascadeType.REMOVE})
private Set<ProductPan> pans;
}
public class ProductPan {
@Id
@Column(name="product_pan_id")
private Long productPanId;
@Fetch(FetchMode.JOIN)
@ManyToOne(optional=true, fetch=FetchType.EAGER)
@JoinColumn(name="product_id", referencedColumnName = "product_id", insertable = false, updatable = false)
private VProduct vProduct;
}
当我尝试查询VProduct表格时,我收到以下异常。
org.hibernate.exception.SQLGrammarException: ERROR: column pans0_.product_pan_id does not exist
我在这里做错了什么?目前,ProductPan表为空。并且它不保证有任何产品用于VProduct。如果那就是问题是否有任何注释我可以添加以忽略该空数据问题?
这是hibernate查询和结果
14:39:49,994 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Hibernate: select pans0_.product_id as product3_101_1_, pans0_.product_pan_id as product1_1_, pans0_.product_pan_id as product1_71_0_, pans0_.pan_id as pan2_71_0_, pans0_.product_id as product3_71_0_ from product_pan pans0_ where pans0_.product_id=?
14:39:50,113 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) SQL Error: 0, SQLState: 42703
14:39:50,116 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) ERROR: column pans0_.product_pan_id does not exist