日期:2014-05-17  浏览次数:20714 次

hibernate查询的问题 java2000_net
select *from productInfo as p JOIN brandInfo as b on p.brand_Id in(select b.brand_Id from brandInfo where b.brand_name like '%雅%') 这个是数据库中用sql写的 可以正确执行 转化为下面hqlsql1的语句就会报错
这里是错误信息:
Caused by: line 1:188: expecting CLOSE, found 'null'
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'null' near line 1, column 188 [ from com.wowo.homefitment.beans.ProductInfo as p inner join p.brandInfo where p.brandInfo.brandId in (select p.brandInfo.brandId from p.brandInfo where p.brandInfo.brandName like'%雅鼎%']
这个是转换的hibernate语句:
String hqlsql1 = " from ProductInfo as p inner join p.brandInfo where p.brandInfo.brandId in (select p.brandInfo.brandId from p.brandInfo where p.brandInfo.brandName like'%"+condition+"%'";


------解决方案--------------------
String hqlsql1 = " from ProductInfo as p inner join p.brandInfo where p.brandInfo.brandId in (select p.brandInfo.brandId from p.brandInfo where p.brandInfo.brandName like'%"+condition+"%'"; 

你转换的这句我没看懂 开头没有select * 结束时少一个括回。不知道是就这么写啊 ?还是你写错了?