Subquery in select clause with Criteria JPA

2

I was researching how to make a subquery in the select clause with Criteria of a select of this type:

SELECT tabela1.*,tabela2.*,
(SELECT MAX(tabela5.AtrDatatabela5) 
FROM .Tabela3 AS tabela3 
    INNER JOIN Tabela4 AS tabela4 ON tabela4.AtrIdTabela4 = tabela3.AtrIdTabela4
    LEFT outer JOIN CraMar AS tabela5 ON tabela5.AtrIdTabela4 = tabela4.AtrIdTabela4
WHERE  tabela4.AtrIdTipoTabela4 = 1
    AND tabela3.AtrIdTabela2 = tabela2.atridTabela2 
    AND tabela3.AtrDataDevolucao IS NULL
    AND tabela5.AtrDataTabela5 between 'Mar 29 2016 00:00' and 'Mar 29 2016 23:59'
    AND tabela5.AtrCodigoTabela5 IN ('E', 'S')) as utlimaTabela5
FROM Tabela1 AS tabela1...
    
asked by anonymous 29.03.2016 / 14:23

1 answer

0

JPA 2.0 does not support sub-query in the SELECT clause. See if you can change your original SQL to achieve the same result without needing this sub-query. From there, it's easier to make an equivalent query with Criteria.

    
19.04.2016 / 19:02