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

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条)

相关推荐 更多相似问题