subselect « HQL « JPA Q&A

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

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

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

2. HQL subselect

3. HQL using a subselect in the from part

Can I use a subselect (sub query) in the from part (instead of a table). e.g. "from (select, count(*) from x as x group by 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

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 ...