| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 887 人关注过本帖
标题:求大神,帮忙看下出了什么问题?关于 HQL 语句的查询
只看楼主 加入收藏
z060831
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2013-8-3
结帖率:50%
收藏
 问题点数:0 回复次数:0 
求大神,帮忙看下出了什么问题?关于 HQL 语句的查询
代码:
public class testHQL2 {
    public static void main(String[] args) {
        AbstractApplicationContext act= new ClassPathXmlApplicationContext("applicationContext.xml");
        ListDao listDao = (ListDao) act.getBean("ilistdao");
        
        String HQL = "SELECT new List(MB001,ISNULL((SELECT ISNULL(SUM(MC007),0) FROM INVMC WHERE MC001=MB001),'')) FROM INVMB B ";
        
        List<List<Object>> data = listDao.findByHQL(HQL, new Object[]{});
        if(data!=null && data.size()>0){
            for(int i=0;i<10;i++){
                System.out.println(data.get(i));
            }
        }
        System.out.println("END");
    }
}


错误提示:
java.lang.NullPointerException
    at org.hibernate.hql.NameGenerator.generateColumnNames(NameGenerator.java:46)
    at org.hibernate.hql.ast.util.SessionFactoryHelper.generateColumnNames(SessionFactoryHelper.java:409)
    at org.hibernate.hql.ast.tree.SelectClause.initializeColumnNames(SelectClause.java:269)
    at org.hibernate.hql.ast.tree.SelectClause.finishInitialization(SelectClause.java:259)
    at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:253)
    at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:831)
    at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:619)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:672)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
    at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
    at org.hibernate.hql.ast.(QueryTranslatorImpl.java:136)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
    at DAO.ListDaoImpl.findByHQL(ListDaoImpl.java:22)
    at testAnythings.testHQL2.main(testHQL2.java:17)
搜索更多相关主题的帖子: Object public null 
2014-08-11 17:57
快速回复:求大神,帮忙看下出了什么问题?关于 HQL 语句的查询
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016923 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved