[英]SQL to Hibernate Query Language (HQL) - missing IN
Desired SQL statement to convert 所需的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
My HQL attempt: 我的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
When I converted the HQL to SQL to test as a result, i get the following: 当我将HQL转换为SQL以进行测试时,得到以下结果:
SQL Error: Missing IN or OUT parameter at index:: 1
HQL doesn't allow use UNION ALL sql construct. HQL不允许使用UNION ALL sql构造。
You must execute two different queries and then you can merge the results of them. 您必须执行两个不同的查询,然后才能合并它们的结果。
So you'll have: 因此,您将拥有:
First query: 第一个查询:
From TableA a where a.columnA is not null
order by cast(a.columnA as int), a.columnB
Second query: 第二个查询:
TableA b where b.columnA is not null order by b.columnB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.