Hi,
I am new to the Hibernate. I am using Spring,Hibernate3 and My Sql 5 with Tomcat 5.
I am using HibernateDAOSupport to get the seesionfactory.
Here is my sample report query :
String sql = "select new Info(t1.userId,datediff(curdate(),max(t2.entryTime))) from Tab1 t1, Tab2 t2 where t1.userId = t2.id group by t1.userId having datediff(curdate(),max(t2.entryTime)) > 3";
results = getSessionFactory().openSession().createQuery(sql).list();
I am getting the following exception only when i use datediff(curdate(),max(t2.entryTime)) function inside the Info constrctor.
java.lang.NullPointerException
org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:215)
org.hibernate.hql.ast.ConstructorNode.resolveConstructor(ConstructorNode.java:112)
org.hibernate.hql.ast.ConstructorNode.prepare(ConstructorNode.java:86)
org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:543)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1598)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1467)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1041)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:380)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
com.fp.hibernate.dao.TestDAOImpl.getInactivityAlerts(AlertsDAOImpl.java:44)
org.apache.jsp.test_jsp._jspService(test_jsp.java:146)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I appreciate your help.
Thanks,
Gopal
|