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
这两条语句有什么问题吗?
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
这两条语句有什么问题吗?
第二种如果用hql语句,只需要对象.属性.属性
可能是select count(*) from Video v, Collectlist c where v.videoId=c.video.videoID and c.user().userID=2
如果有问题,想写hql的话最好把三个实体类都贴出来。想写sql的话表和字段也要贴出来
第二种写法很混乱,对于hql语句用法需详细理解...