The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

nverma (1) [Avatar] Offline
#1
How does hibernate handle UNION in a SQL. I have to run a query that selects a different set of columns from the same table based on a parameter. I have to use the union clause, but I can't find any lead on how would Hibernate's Query object address this issue.

For a table say, Employee with columns, Id, FName, LName, I want to do the following

select ID, FName as Name where LName is null
UNION
select ID, LName as Name where FName is null
order by 2

How can I do it using Hibernate's Query object

Any help would be appreciated

THanks,