hibenrnate的HQL查询注意

比如这是一条正确的HQL语句:      
   String queryString="select new com.dio.blog.dto.UserListDto(fu.username,fu.nickName,fu.url,fu.level,fu.charactor,fua.fid,fua.realName) from FriendUser fu,FriendUserAssociation fua where fu.id in(select fuab.fid from FriendUserAssociation fuab where fuab.uid=?)and fu.id=fua.fid and fua.uid=?";
如果这样写就会报错:     
     String queryString="select new com.dio.blog.dto.UserListDto(fu.username,fu.nickName,fu.url,fu.level,fu.charactor,fua.fid,fua.realName) from FriendUser fu,FriendUserAssociation fua where fu.id in(select FriendUserAssociation .fid from FriendUserAssociation fuab where FriendUserAssociation .uid=?)and fu.id=fua.fid and fua.uid=?";

这个例子说明:HQL查询时,如果要查询表中的字段,只能用别名。,不能用类名;

你可能感兴趣的:(Blog)