Здравствуйте, у меня есть запрос HQL, как показано ниже в моем классе DAO.
String queryString1 = "select new com.apple.ist.cm.ruleadmin.model.SearchQuestionnaire(qc.questionCategoryID,qc.questionCategoryName, qn.questionReferenceString, qn.question,qao.answerOptionGroupID,answerOptionGroup,answerStringValue) " +" from Questionnaire qn,QuestionCategory qc,QuestionAnswerOption qao,AnswerOptionGroup aog,AnswerString ans "+"where qn.questionCategoryID = qc.questionCategoryID and qn.questionID=qao.questionID and qao.answerOptionGroupID=aog.answerOptionGroupID and qao.answerStringID=ans.answerStringID";
SearchQuestionnaire quest = null;
query1 = (List<SearchQuestionnaire>) hibernateTemplate.find(queryString1);
и у меня есть все модели, сопоставленные с 5 таблицами:
- AnswerOptionGroup.java
- AnswerString.java
- QuestionAnswerOption.java
- QuestionCategory.java
- QuestionCategory.java.
И SearchQuestionnaire.java - это фиктивное pojo для передачи с запросом с установщиками-получателями для всех выбранных столбцов из вышеприведенного запроса.
public class SearchQuestionnaire {
private long questionCategoryID;
private String questionCategoryName;
private String questionReferenceString;
private long questionCategory;
private String question;
private long answerOptionGroupID;
private String answerOptionGroup;
private String answerStringValue;
public SearchQuestionnaire(){
}
public SearchQuestionnaire(long answerOptionGroupID,String answerOptionGroup){
this.questionCategoryID = questionCategoryID;
this.questionCategoryName = questionCategoryName;
this.questionReferenceString = questionReferenceString;
this.question = question;
this.answerOptionGroupID = answerOptionGroupID;
this.answerOptionGroup = answerOptionGroup;
this.answerStringValue = answerStringValue;
}
.......все геттеры и сеттеры}
Здесь с вышеприведенным я получаю ошибку ниже:
20:05:50,561 ERROR [STDERR] java.lang.NullPointerException
20:05:50,562 ERROR [STDERR] at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:195)
20:05:50,562 ERROR [STDERR] at org.hibernate.hql.ast.tree.ConstructorNode.resolveConstructor(ConstructorNode.java:137)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:111)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:862)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1956)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1825)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1394)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:553)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
20:05:50,563 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
20:05:50,563 ERROR [STDERR] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
20:05:50,564 ERROR [STDERR] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
20:05:50,564 ERROR [STDERR] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
20:05:50,564 ERROR [STDERR] at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
20:05:50,564 ERROR [STDERR] at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
20:05:50,564 ERROR [STDERR] at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:914)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
20:05:50,564 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
20:05:50,565 ERROR [STDERR] at com.apple.ist.cm.ruleadmin.dao.QuestionnaireDAOImpl.listQuestionnaire(QuestionnaireDAOImpl.java:300)
20:05:50,565 ERROR [STDERR] at com.apple.ist.cm.ruleadmin.controllers.QuestionnaireController.listQuestionnaire(QuestionnaireController.java:121)
20:05:50,565 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20:05:50,565 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
20:05:50,565 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
20:05:50,565 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
20:05:50,565 ERROR [STDERR] at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
20:05:50,565 ERROR [STDERR] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
20:05:50,565 ERROR [STDERR] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
20:05:50,565 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
20:05:50,566 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
20:05:50,566 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
20:05:50,566 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
20:05:50,566 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
20:05:50,566 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
20:05:50,566 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
20:05:50,566 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
20:05:50,566 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
20:05:50,566 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
20:05:50,567 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
20:05:50,567 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
20:05:50,567 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
20:05:50,567 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
20:05:50,567 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
20:05:50,567 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
20:05:50,567 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
20:05:50,567 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
20:05:50,567 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
20:05:50,567 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
20:05:50,567 ERROR [STDERR] at java.lang.Thread.run(Thread.java:680)
Но если я попробовал с приведенным ниже запросом в DAO, он работает нормально
String queryString1 = "select new com.apple.ist.cm.ruleadmin.model.SearchQuestionnaire(qc.questionCategoryID,qc.questionCategoryName,qn.questionReferenceString, question)"
+" from Questionnaire qn,QuestionCategory qc where qn.questionCategoryID = qc.questionCategoryID";
Пожалуйста, помогите мне в разрешении "NullPointerException".