Erro no Hibernate (in expected)!

2 respostas
G

Galera,

Dêem uma olhada nesse HQL. A tabela chama VwImovelCustoCusVo. Os atributos cdRegiao e cdEntidadeCusto estão corretos. O q pode estar ocasionando esse erro??

net.sf.hibernate.QueryException: in expected: vw [select vw from VwImovelCustoCusVo vw where vw.cdRegiao = 8 and vw.cdEntidadeCusto = 715]

net.sf.hibernate.hql.FromParser.token(FromParser.java:102)

net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)

net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)

net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)

net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)

net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)

net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)

net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1554)

net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1525)

net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)

net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1505)

br.org.df.codeplan.sigterra.dao.BaseDAO.findAll(BaseDAO.java:123)

br.org.df.codeplan.sigterra.dao.ContabilDAO.findDadosRelatorioCustos(ContabilDAO.java:569)

br.org.df.codeplan.sigterra.facade.ContabilFacade.findDadosRelatorioCustos(ContabilFacade.java:316)

br.org.df.codeplan.sigterra.struts.contabil.emiteRelatorioCustosContabil.EmiteRelatorioCustosContabilAction.exibirRelatorio(EmiteRelatorioCustosContabilAction.java:87)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

java.lang.reflect.Method.invoke(Method.java:585)

org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)

org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)

org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)

org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

javax.servlet.http.HttpServlet.service(HttpServlet.java:709)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Obrigado, Guilherme

2 Respostas

D

Coloca ai pra gente ver como vc fez a query.

De forma geral seria assim:

session.createQuery("from VwImovelCustoCusVo vw where vw.cdRegiao = 8 and vw.cdEntidadeCusto = 715");
N

Beleza, irmão?

Cara, comigo aconteceu esse erro quando eu esqueci de colocar alguma classe na SessionFactory, veja o código

static { try { // Create the SessionFactory factory = new Configuration() .addClass(SuasClassesAqui.class) (...) .buildSessionFactory(); } catch (Throwable ex) { System.out.println( "Initial SessionFactory creation failed."); throw new ExceptionInInitializerError(ex); } }

Todas as classes mapeadas no hibernate que serão usadas na sua classe devem estar dentro da factory, ok?

Paz!

Criado 20 de junho de 2005
Ultima resposta 24 de jun. de 2005
Respostas 2
Participantes 3