2010-02-01 77 views

回答

3

我figered如何處理:

Product as p join fetch p.inventories as i join fetch i.inventoryUser as iu join fetch iu.user as u where u.name=:name 
2

在您的實體和映射中,您應該爲每個關係都提供參考。和你的HQL查詢將如下所示:

SELECT p FROM Product p, IN(p.inventory.inventoryUser) AS iu 
    WHERE iu.username=:username 
+0

嘿嘿,如果它只會是那麼容易。我已經試過這一點,但由於事實inventoryUser是一個集合Hibernate拋出一個'QueryException:非法嘗試解引用集合' – woezelmann 2010-02-01 11:47:48

+0

已更新。我還沒有嘗試過,但加入是 – Bozho 2010-02-01 12:06:28

+0

沒有,仍然得到:'HibernateQueryException:非法嘗試取消集合[product0_.id.inventories]元素屬性參考[inventoryUser]' – woezelmann 2010-02-01 14:37:17