Personal speech,
I'm having a problem trying to run an HQL in my application.
HQL is basically this:
select c.id, c.solicitante from <mypackage>.Exame c
LEFT OUTER JOIN <mypackage>.Profissional prof
Java code:
hql = "select c.id, c.solicitante from <mypackage>.Exame c LEFT OUTER JOIN <mypackage>.Profissional prof";
session = HibernateUtil.currentSession();
Query query = session.createQuery(hql);//o erro acontece aqui
and the exception is as follows:
Caused by: java.lang.NullPointerException
at <mypackage>.DaoBase.executarQuery(DaoBase.java:129)
at <mypackage>.RelatoriosBean.gerarRelatorio(RelatoriosBean.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:528)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)
at com.sun.el.parser.AstValue.invoke(AstValue.java:248)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
I'm not an HQL expert, but I know you do not need to explicitly WITH after the JOIN clause.
I really do not know what it can be. This happens with any relationship I have in my class. As a report tool, if I just select primitive type fields (eg, String, Integer, etc.), HQL runs normally.
And yes, I did a lot of research on how to develop HQL, I also looked for someone who has already encountered this problem, but so far no proposed solution has helped me ...
Thanks in advance for any help!