subselect « HQL « JPA Q&A





1. Cant use subselect inside Then on case when ... then ... else    stackoverflow.com

Trying to execute a subselect inside a case when with this query:

select p.id as id, 
   (case when (select count(vo) from ProdutoCustoVO vo where  vo.produto = p) > ...

2. HQL subselect    forum.hibernate.org

3. HQL using a subselect in the from part    forum.hibernate.org

Can I use a subselect (sub query) in the from part (instead of a table). e.g. "from (select x.name, count(*) from x as x group by x.name) as x_values where ..."? Basically are there any constraints on HQL syntax except of the fact that the DB needs to understand the requested syntax?

4. Subselect HQL    forum.hibernate.org

Hello! This query works in mysql: select * from table1 w1 where user_id= 3 and column1 = (select Max(column1) from table1 w2 where w1.column2 = w2.column2 and user_id= 3) group by column2 As you can see, I need the Max column1 and the row that has the max column1. How can I get it to work in HQL. i use Hibernate ...