【发布时间】:2018-01-31 23:32:49
【问题描述】:
这是我的 hql 请求:
@Query("select a from Agent where a.visibility = true a order by a.id desc")
public Page<Agent> getAllAgents(Pageable pageable);
我想选择所有可见性为真的代理。
在我的代理类中,具有布尔可见性属性以及 getVisibility 和 setVisibility 函数。在我的数据库中存储为 bit(1) 的“可见性”。
我试过 a.visibility = 1, ... = '1', ...= 'TRUE', ...='true', ... 是真的。但我得到这个错误:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: a near line 1, column 74 [select a from com.GemCrmTickets.entities.Agent where a.visibility = true a order by a.id desc]
有什么建议吗?提前谢谢你。
【问题讨论】:
-
如果你使用
@Query("select a from Agent where a.visibility = 1 a order by a.id desc")你不会得到同样的错误 -
您的查询中
true后面有一个a,这会使查询无效。 -
不要一遍又一遍地问同一个问题!!!
标签: spring hibernate spring-boot hql