Dúvidas com HQL - SQLGrammarException: could not execute query (help me!)

Galera que saca de HQL, queria saber se a instruções abaixo foram escritas corretamente porque ao rodar o projeto apresenta
erros citados no final. Se alguem puder me ajudar eu agradeço muitissimo.

List lista = gerPersist.find(“from " + Financeiro.class.getName() +
" as f where f.idCtl=” + idCtlSel + filtro +
" and f.codigoUf=’" + uf + “’ AND f.contratado >’”+sum+"’ order by f.contratado", 50);

for (int i = 0; i < lista.size(); i++) { //DÁ ERRO NESTA LINHA

}

List lista = gerPersist.find(“from " + Financeiro.class.getName() +
" as f where f.idCtl=” + idCtlSel + filtro +
" and f.codigoUf=’" + uf + “’ AND f.contratado <=’”+sum+"’ order by f.contratado", 50);

 for (int i = 0; i < lista.size(); i++) {  //DÁ ERRO NESTA LINHA

ERROS MOSTRADOS AO EXECUTAR:
java.lang.NullPointerException
at java.lang.Thread.run(Unknown Source)
org.hibernate.exception.SQLGrammarException: could not execute query –

O que é passado com a variável filtro?

E edite seu post e coloque seu código entre as tags code, tá sofrível ler do jeito que está.

Flw! :thumbup:

Cara… a tua lista esta retornando vazia…

Ve no LOG o SQL que eh gerado pela tua HQL e verifica se tras algum resultado…

Abs :wink:

[quote=bean]Galera que saca de HQL, queria saber se a instruções abaixo foram escritas corretamente porque ao rodar o projeto apresenta
erros citados no final. Se alguem puder me ajudar eu agradeço muitissimo.

List lista = gerPersist.find(“from " + Financeiro.class.getName() +
" as f where f.idCtl=” + idCtlSel + filtro +
" and f.codigoUf=’" + uf + “’ AND f.contratado >’”+sum+"’ order by f.contratado", 50);

for (int i = 0; i < lista.size(); i++) { //DÁ ERRO NESTA LINHA

}

List lista = gerPersist.find(“from " + Financeiro.class.getName() +
" as f where f.idCtl=” + idCtlSel + filtro +
" and f.codigoUf=’" + uf + “’ AND f.contratado <=’”+sum+"’ order by f.contratado", 50);

 for (int i = 0; i < lista.size(); i++) {  //DÁ ERRO NESTA LINHA

ERROS MOSTRADOS AO EXECUTAR:
java.lang.NullPointerException
at java.lang.Thread.run(Unknown Source)
org.hibernate.exception.SQLGrammarException: could not execute query --[/quote]

Começa no from?

from " + Financeiro.class.getName() + 
select coluna1, coluna2, colunas from tabela

[quote=truck1n]Começa no from?

from " + Financeiro.class.getName() + 

Usando JPA, se for carregar o objeto todo, sim, pode começar no from.

Faz o seguinte… Pega o Log do SQL que o Hibernate gera e executa no teu SGBD Adiminitrator…

Falows :wink: