node to traverse cannot be null (Hibernate SQL)

前端 未结 6 1602
醉酒成梦
醉酒成梦 2021-02-12 03:23

I\'m performing a SQL query through hibernate, which looks like:

SELECT thi 
FROM track_history_items thi 
JOIN artists art 
  ON thi.artist_id = art.id 
WHERE t         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-12 04:12

    If you are using Hibernate 4 you should be calling:

    Query query = session.getNamedQuery(Entity.NAMED_QUERY);
    

    instead of

    Query query = session.createQuery(Entity.NAMED_QUERY);
    

    This happens because session.createQuery will try to create the query based on the string value of Entity.NAMED_QUERY for example:

    String NAMED_QUERY = "Entity.namedQuery";
    

    resulting in a incorrect HQL and raising a exception.

提交回复
热议问题