遍历节点不能为空(Hibernate SQL) [英] node to traverse cannot be null (Hibernate SQL)
问题描述
我通过hibernate执行SQL查询,如下所示:
SELECT thi
FROM track_history_items thi
JOIN artists art
ON thi.artist_id = art.id
WHERE thi.type =TrackBroadcast
GROUP BY art.name
ORDER thi.createdAt DESC
但我收到'Node遍历的消息不能为null!'的消息。任何人都知道这可能是什么原因造成的?
- 编辑 -
我很确定这个问题是由artist_id为空的可能性引起的。但是,我无法阻止这种情况,所以我可以跳过行数为空的artist_id行吗?
要遍历的节点不能为null!
这是一个泛型Hibernate错误消息,指出查询中的语法问题。作为另一个例子,忘记使用单词SELECT来启动select子句会产生相同的错误。在这种情况下,语法错误是由于on子句导致的 - HQL不支持它们。
FROM track_history_items thi,artists art
WHERE thi.type =TrackBroadcast
AND thi.artist_id = art.id
GROUP BY art.name
ORDER thi.createdAt DESC
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 thi.type = "TrackBroadcast"
GROUP BY art.name
ORDER thi.createdAt DESC
but I'm getting the message that 'Node to traverse cannot be null!'. Anyone know what could be causing this?
--EDIT--
I'm pretty sure that this problem is being caused by the possibility of artist_id to be null. However, I can't prevent this, so can I just skip the rows track_history_item rows which have a null artist_id?
node to traverse cannot be null!
This is a generic Hibernate error message indicating a syntax problem in your query. As another example, forgetting to start a select clause with the word "SELECT" would yield the same error.
In this instance the syntax error is due to the on clause - HQL does not support them. Instead do a cross join like so:
FROM track_history_items thi, artists art
WHERE thi.type = "TrackBroadcast"
AND thi.artist_id = art.id
GROUP BY art.name
ORDER thi.createdAt DESC
这篇关于遍历节点不能为空(Hibernate SQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!