com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'productId3' in 'where clause'
尝试运行此查询时出现错误:
public Vendor getVendorId(ProductInfo productInfo) {
return (Vendor) this.sessionFactory
.getCurrentSession()
.createQuery(
"select vendorId from Product where productId3 = :id")
.setParameter("id", productInfo).uniqueResult();
}
Product 类如下所示:
@Entity
@Table(name="PRODUCT")
public class Product{
@Id
@GeneratedValue
@Column(name="PRODUCT_ID2")
private Integer productId2;
public void setProductId2(Integer productId2){
this.productId2 = productId2;
}
public Integer getProductId2(){
return productId2;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="PRODUCT_ID3")
private ProductInfo productId3;
public void setProductId3(ProductInfo productId3){
this.productId3 = productId3;
}
public ProductInfo getProductId3(){
return productId3;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="VENDOR_ID")
private Vendor vendorId;
public void setVendorId(Vendor vendorId){
this.vendorId = vendorId;
}
public Vendor getVendorId(){
return vendorId;
}
@OneToMany(mappedBy="productId2")
private Set<ProductRevision> productRevisions;
public void setProductRevisions(Set<ProductRevision> productRevisions){
this.productRevisions = productRevisions;
}
public Set<ProductRevision> getProductRevisions(){
return productRevisions;
}
}
为什么我会收到此错误?我不明白为什么它找不到列,因为名称完全相同。谢谢你的帮助!
/D