Java SQL到Hibernate查询语言(HQL)-中缺少

Java SQL到Hibernate查询语言(HQL)-中缺少,java,sql,hql,Java,Sql,Hql,要转换的所需SQL语句 select * from tableA where columnA is not null order by cast(columnA as int), columnB union all select * from app_data_program where columnA is null order by columnB 我的HQL尝试: From TableA a where a.columnA is not null order by cast(a.co

要转换的所需SQL语句

select * from tableA where columnA is not null 
order by cast(columnA as int), columnB
union all
select * from app_data_program where columnA is null order by columnB
我的HQL尝试:

From TableA a where a.columnA is not null 
order by cast(a.columnA as int), a.columnB 
union all TableA b where b.columnA is not null order by b.columnB
当我将HQL转换为SQL以进行测试时,我得到以下结果:

SQL Error: Missing IN or OUT parameter at index:: 1

HQL不允许使用UNIONALL sql构造

必须执行两个不同的查询,然后才能合并它们的结果

因此,您将有:

第一个问题:

From TableA a where a.columnA is not null 
order by cast(a.columnA as int), a.columnB
第二个问题:

TableA b where b.columnA is not null order by b.columnB

查询中有一个“?”参数应该放在哪里。你是在执行你的陈述之前设置这个参数的吗?我删除它是为了让事情更简单。谢谢你在用什么数据库?谷歌搜索这个错误看起来像是甲骨文的某个版本。(谷歌还提供了一些可能值得研究的链接。)也许这会有所帮助:合并不会产生重复的结果吗?你的查询使用UNIONALL(而不是放弃重复)。您可以放弃Java循环中的重复项