Nhibernate HQL Subquery Requests

I have the following SQL query:

select c.id from (select id from customers) c 

This query has no practical meaning - I greatly simplified it for this publication.

My question is: is it possible to have a subquery in a from clause using HQL. If not, can I possibly first query clients as a temporary table in sql and then use the result as the source of the next query?

thanks

+4
source share
2 answers

Yes it is possible.

The above query can be written in HQL as follows:

 select Id from Customer where Id in (select Id from Customer) 
+7
source

I myself ran into this problem. It took some time to realize that hql does not support subqueries in the from clause.

See section 14.13 in the hql documentation here .

+3
source

All Articles