Hibernate Criteria - SubQuerie

2 respostas
V

Pessoal,

Tenho esse select feito em SQL e quero fazer com HQL, só que ta foda, alguem pode ajudar…

SELECT * FROM PROJETOTAREFA AS PT WHERE (SELECT COUNT(*) from projetotarefa where idprojeto = PT.IDPROJETO group by idprojeto) = (SELECT COUNT(*) from projetotarefa where idprojeto = PT.IDPROJETO and status = 'CONCLUIDA' group by idprojeto)

2 Respostas

F

Você já tem o mapeamento da tabela? Já desenvolveu o hql e deu algum erro?

V

Cara eu consegui fazer com HQL e ficou assim:

Query q = session.createQuery("FROM ProjetoTarefa as pt where " + "(select count(*) from ProjetoTarefa where chaveComposta.projeto.id = pt.chaveComposta.projeto.id) = " + "(select count(*) from ProjetoTarefa where chaveComposta.projeto.id = pt.chaveComposta.projeto.id and status = 'CONCLUIDA')");

sabe com fazer com criteria?

Criado 25 de maio de 2010
Ultima resposta 26 de mai. de 2010
Respostas 2
Participantes 2