select count(*) from Video v, Collectlist c where v.videoId=c.videoID and c.userID=2这条语句有问题吗?
Video表内videoID是主键,Collectlist里videoID,userID是外键,查询Collectlist表里用户ID为2的所有Video属性信息,
在Query query = getSession().createQuery(hql);处报错,报错的信息说could not resolve property: userID of: com.coe.entity.Collectlist试了select count(*) from Video v, Collectlist c where v.videoId=c.getVideo().videoID and c.getUser().userID=2,也还是在Query query = getSession().createQuery(hql);报错,不过报错是10:21:30,356 ERROR PARSER:33 - <AST>:1:101: unexpected AST node: (
java.lang.NullPointerException
这两条语句有什么问题吗?

解决方案 »

  1.   

    第一种不知道干嘛,好像把hql写法和sql写法混了起来,还有数据库字段确定一下
    第二种如果用hql语句,只需要对象.属性.属性
          可能是select count(*) from Video v, Collectlist c where v.videoId=c.video.videoID and c.user().userID=2
    如果有问题,想写hql的话最好把三个实体类都贴出来。想写sql的话表和字段也要贴出来
      

  2.   

    Collectlist类里面你可能写的字段不是叫userID ,第二个是你hql语句就写错了,第一个写法是正确的
      

  3.   

    Collectlist类里面可能不是叫userID,或者userID没有get方法
      

  4.   

    第一种写法:select count(*) from Video v, Collectlist c where v.videoId=c.videoID and c.userID=2换成select count(V) from Video v, Collectlist c where v.videoId=c.videoID and c.userID=2,顺便再检查下Collectlist中userID属性注入是否正确
    第二种写法很混乱,对于hql语句用法需详细理解...