Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HIbernate HQL意外令牌_Java_Hibernate_Hsqldb - Fatal编程技术网

Java HIbernate HQL意外令牌

Java HIbernate HQL意外令牌,java,hibernate,hsqldb,Java,Hibernate,Hsqldb,我有以下Hibernate查询: String HSQL = "from Page as p " + "where not exists (from Link as l where l.dealId = p.id) " + "and p.userId = :userId"; return (List<Deal>) sessionFactory.getCurrentSession() .createQuery(HSQL) .setParameter("userId",

我有以下Hibernate查询:

String HSQL = "from Page as p "
  + "where not exists (from Link as l where l.dealId = p.id) "
  + "and p.userId = :userId";

return (List<Deal>) sessionFactory.getCurrentSession()
  .createQuery(HSQL)
  .setParameter("userId", userId)
  .list();
我的Hibernate版本是5.4.1


查询有什么问题?

我认为在您的实体中,
dealId
属于
Page
类型,而不是
Long
类型,因此您可以使用:

"where not exists (from Link as l where l.dealId = p) "
                                        ^^^^^^^^^^^^

据我所知,在HQL查询中声明别名之前,没有必要将
用作
dealId的类型是什么
您可以分享您的实体吗?实际上,
SELECT
在HQL中应该是可选的,至少对于外部查询是这样。请看这里:Hi@TimBiegeleisen,我同意这是可选的,你的问题中有一部分我不明白。对不起,你能澄清一下吗:)谢谢,这让我找到了解决办法。实体没有dealId属性,但交易本身具有。所以如果我这样做了,它就开始工作了。
"where not exists (from Link as l where l.dealId = p) "
                                        ^^^^^^^^^^^^