Galera, me ajudem a encontrar o erro na minha query, estou usando NativeQuery em java e está me retornando um segue, segue o código:
@Stateless
public class NfceServiceImpl extends ConsultasDaoJpa<NotaEmpresas> implements NfceService {
private final String QUERY = "select "
+ "infnfe.id_infnfe as chave_nfce, "
+ "infnfe.cnpj_emitente emit_cnpj, "
+ "ide.nnf as numero_nfce, "
+ "ide.serie as serie_nfce, "
+ "ide.tpNF as tpNF_nfce, "
+ "ide.tpEmis as tpEmis_nfce, "
+ "ide.dhemi as dhEmi_nfce, "
+ "icmstot.VNF AS total_vNF, "
+ "dest.CPF + dest.CNPJ + dest.ID_ESTRANGEIRO as dest "
+ "from SEFAZ_NFC.TB_INFNFE infnfe "
+ "left join SEFAZ_NFC.TB_IDE ide on ide.ID_IDE = infnfe.ID_IDE "
+ "left join SEFAZ_NFC.TB_TOTAL total on infnfe.ID_TOTAL = total.ID_TOTAL "
+ "left join SEFAZ_NFC.TB_ICMSTOT icmstot on icmstot.ID_ICMSTOT = total.ID_ICMSTOT "
+ "left join SEFAZ_NFC.TB_dest dest on infnfe.id_dest = dest.id_dest "
+ "where ide.dhemi between TO_DATE(:dataInicial,'dd/mm/yyyy') and TO_DATE(:dataFinal,'dd/mm/yyyy');";
@Override
public List<NotaEmpresas> buscarPorData(String dataInicioFormatada, String dataFimFormatada) {
List<NotaEmpresas> listNota = null;
try {
Query sqlQuery = em.createNativeQuery(QUERY, NotaEmpresas.class);
sqlQuery.setParameter("dataInicial", dataInicioFormatada);
sqlQuery.setParameter("dataFinal", dataFimFormatada);
listNota = (List<NotaEmpresas>) sqlQuery.getResultList();
} catch (NoResultException ex) {
System.out.println("Lista nota não encontrada!");
}
return listNota;
}
}
Erro retornado:
15:10:34,726 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-34) SQL Error: 911, SQLState: 42000
15:10:34,726 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-34) ORA-00911: caractere inválido
15:10:34,731 ERROR [org.jboss.as.ejb3.invocation] (default task-34) JBAS014134: EJB Invocation failed on component NfceServiceImpl for method public abstract java.util.List br.com.nfce.services.NfceService.buscarPorData(java.lang.String,java.lang.String): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)