[英]SQL to Hibernate Query Language (HQL) - missing IN
所需的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不允許使用UNION ALL 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.