hibenrnate的HQL查询注意

[color=green]比如这是一条正确的HQL语句:[/color]
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=?";
[color=green]如果这样写就会报错:[/color]
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 [color=red]FriendUserAssociation [/color].fid from FriendUserAssociation fuab where [color=red]FriendUserAssociation [/color].uid=?)and fu.id=fua.fid and fua.uid=?";

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值