javalaz 2010-06-14 12:22
浏览 258
已采纳

org.hibernate.hql.ast.tree.PathNode异常解决

java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode cannot be cast to org.hibernate.hql.ast.tree.PathNode
    at org.hibernate.hql.ast.tree.ConstructorNode.prepare(ConstructorNode.java:128)
    at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:982)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2120)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1981)
 public Member() {
    }
    public Member(String memberId,String memberName){
        this.memberId = memberId;
        this.memberName = memberName;
    }
     getHibernateTemplate().find("select new Member(mb.memberId,mb.memberName)from Member mb");

  • 写回答

2条回答 默认 最新

  • zxtzxz 2010-06-14 13:50
    关注

    Hql语法中提到:
    select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr假设类Family有一个合适的构造函数.
    所以你的应该是
    select new Member(mb,mb.memberId,mb.memberName)from Member mb或者
    select new Member(mb,memberId,memberName)from Member as mb join mb.memberId as memberId left join mb.memberName as memberName

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 STM32L431RCT6 定时器2中断发起ADC 采样问题
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢
  • ¥15 docker部署Mongodb后输入命令报错?
  • ¥15 将下列流程图转变成python程序代码
  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序
  • ¥15 如何解决Excel中dependent dropdown list 的问题
  • ¥15 MddBootstrapInitialize2失败
  • ¥15 LCD Flicker