@JoinColumn(name = "want_uid", referencedColumnName = "id")
@ManyToOne
private BookUsers wantUid;
@JoinColumn(name = "sale_uid", referencedColumnName = "id")
@ManyToOne
private BookUsers saleUid;
@JoinColumn(name = "book_id", referencedColumnName = "id")
此代码来自实体bean 我使用want_uid作为queryparam写一个查询.as fllows:
BookUsers bookUsers=userDA.findUserByID(wantID);
Query query= em.createQuery("SELECT b FROM BookOrder b WHERE b.want_uid = :want_uid");
query.setParameter("want_uid", bookUsers);
发生了异常:
javax.servlet.ServletException: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Error compiling the query [SELECT b FROM BookOrder b WHERE b.want_uid = :want_uid], line 1, column 34: unknown state or association field [want_uid] of class [com.xbook.entities.BookOrder].
我没找到原因...... 你能告诉我吗 ? 感谢
答案 0 :(得分:2)
在查询中
b.want_uid
需要更改为
b.wantUid
所以,
SELECT b FROM BookOrder b WHERE b.wantUid = :want_uid