首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

hibernate关联查询java.lang.NullPointerException的原因

2014-01-26 
查询代码org.hibernate.Session hSession nullhSession HibernateUtilPlus.currentSession()String h

查询代码
  org.hibernate.Session hSession = null;
  hSession = HibernateUtilPlus.currentSession();
  String hql="from TabUser as user inner join user.userId";
  Query query = hSession.createQuery(hql);这句抛异常
  List myPrivilegeList=query.list();
  异常信息:
  java.lang.NullPointerException
 
  at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:264)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3022)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2841)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
 
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
 
  at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
 
  at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
 
  at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
 
  at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
 
  at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
 
  at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
 
  at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
 
  at com.monitorcc.comm.action.ListPrivilegeAction.execute(ListPrivilegeAction.java:50)
 
  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
 
  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
 
  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
 
  at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
 
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
 
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
 
  at com.monitorcc.common.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:145)
 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
 
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
 
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
 
  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
 
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
 
  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
 
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 
  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)         

热点排行