longtengsoft 2009-02-16 19:19
浏览 374
已采纳

spring+hibernate query.list 报空指针

Hibernate: select count(*) as col_0_0_ from profession profession0_ where profession0_.dept_no=?
Hibernate: select top 12 profession0_.profession_No as profession1_1_, profession0_.profession_name as profession2_1_, profession0_.dept_no as dept3_1_ from profession profession0_ where profession0_.dept_no=? order by profession0_.profession_No desc
2009-2-16 19:10:01 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.top.daoHibernateImpl.HibernateGeneric.pagedQuery(HibernateGeneric.java:264)

    Assert.hasText(hql);
    Assert.isTrue(pageNo >= 1, "pageNo should start from 1");
    // Count查询
    String countQueryString = PageFactory.getTotalCountHqlByHql(hql);
    List countlist = this.find(countQueryString, values);
    int totalCount = ((Integer) countlist.get(0)).intValue();



    if (totalCount < 1) return new Page();
    // 实际查询返回分页对象
    Query query = createQuery(hql, values);
    int startIndex = PageFactory.getStartIndex(pageNo, pageSize);
    List results = query.setFirstResult(startIndex).setMaxResults(pageSize)
            .list();//本行报空指针
    return PageFactory.createPage(pageNo, pageSize, totalCount, results);

[b]问题补充:[/b]
大家好本问题已经解决!~
我才本站其他贴上看到了同样的贴,再此也谢谢那位仁兄!~

  • 写回答

1条回答 默认 最新

  • yighter 2009-02-16 22:51
    关注

    有没有可能起始行数过大?
    debug一下startIndex的值。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用python处理excel的数据(极值标准化)
  • ¥15 三向应力状态求剪应力
  • ¥15 jupyter notebook如何添加libGL.so.1库
  • ¥20 easyPoi能否实现下拉多选或者复选框
  • ¥15 网桥在转发帧时,会变帧的源地址和目的地址吗?
  • ¥15 用Multisim设计汽车尾灯控制电路
  • ¥100 求用matlab求解上述微分方程的程序代码
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析