当前位置: 代码迷 >> Java Web开发 >> !问一个HQL 和SQL 的有关问题 SQL 可以跑 HQL 出有关问题!
  详细解决方案

!问一个HQL 和SQL 的有关问题 SQL 可以跑 HQL 出有关问题!

热度:489   发布时间:2016-04-17 10:19:46.0
!!!问一个HQL 和SQL 的问题 SQL 可以跑 HQL 出问题!!!急!!
HQL 是这样的

SELECT u FROM Product u WHERE u.vvshop =true and u.commend = true and u.id in ( SELECT v.productId FROM (SELECT distinct rp.product.id,rp.recommendNum FROM RecommondProType rp where rp.recommondType in (:recommondTypes) and rp.warehouse=:warehouseId order by rp.recommendNum desc) v )?

SQL是可以跑 的
Java code
select *  from (select product0_.ID                    as ID75_,               product0_.name                  as name75_,               product0_.smpic                 as smpic75_,               product0_.marketPrice           as marketPr4_75_,               product0_.brand                 as brand75_,               product0_.brandName             as brandName75_,               product0_.brandSerialNum        as brandSer7_75_,               product0_.newAttributes         as newAttri8_75_,               product0_.status                as status75_,               product0_.model                 as model75_,               product0_.properPayType         as properP11_75_,               product0_.productClass          as product12_75_,               product0_.memberPrice           as memberP13_75_,               product0_.unit                  as unit75_,               product0_.store                 as store75_,               product0_.supplier              as supplier75_,               product0_.parking               as parking75_,               product0_.weight                as weight75_,               product0_.volume                as volume75_,               product0_.description2          as descrip20_75_,               product0_.otherExplain2         as otherEx21_75_,               product0_.howtobuy              as howtobuy75_,               product0_.spec                  as spec75_,               product0_.tags                  as tags75_,               product0_.commend               as commend75_,               product0_.dealerAdd             as dealerAdd75_,               product0_.onlineSale            as onlineSale75_,               product0_.tradingAmount         as trading28_75_,               product0_.vvshop                as vvshop75_,               product0_.booking               as booking75_,               product0_.ifEntity              as ifEntity75_,               product0_.getProductDay         as getProd32_75_,               product0_.pinyinIndex           as pinyinI33_75_,               product0_.no                    as no75_,               product0_.marketing             as marketing75_,               product0_.iternationalCode      as iternat36_75_,               product0_.iternationalCodeNote  as iternat37_75_,               product0_.adminusername         as adminus38_75_,               product0_.companyname           as company39_75_,               product0_.productlevel          as product40_75_,               product0_.procurementuser       as procure41_75_,               product0_.packagemodel          as package42_75_,               product0_.productCountry        as product43_75_,               product0_.productrovince        as product44_75_,               product0_.productcity           as product45_75_,               product0_.saletype              as saletype75_,               product0_.productcolour         as product47_75_,               product0_.recommendNum          as recomme48_75_,               product0_.createDate            as createDate75_,               product0_.publishDate           as publish50_75_,               product0_.specialSize           as special51_75_,               product0_.delChange             as delChange75_,               product0_.purchasePrice         as purchas53_75_,               product0_.specParameter         as specPar54_75_,               product0_.proContentDetail      as proCont55_75_,               product0_.afterSellService      as afterSe56_75_,               product0_.presentBelong         as present57_75_,               product0_.orderOverQty          as orderOv58_75_,               product0_.productModel          as product59_75_,               product0_.consignmentPrice      as consign60_75_,               product0_.isEditInvContent      as isEditI61_75_,               product0_.productAnnotation     as product62_75_,               product0_.productSaleRankNo     as product63_75_,               product0_.oldForNew             as oldForNew75_,               product0_.pfDateFlag            as pfDateFlag75_,               product0_.shelfLife             as shelfLife75_,               product0_.packStandard          as packSta67_75_,               product0_.stockUpLimit          as stockUp68_75_,               product0_.stockLowerLimit       as stockLo69_75_,               product0_.classification        as classif70_75_,               product0_.fragileFlag           as fragile71_75_,               product0_.qualityCheckFlag      as quality72_75_,               product0_.allowNoStockSale      as allowNo73_75_,               product0_.factorySendFlag       as factory74_75_,               product0_.length                as length75_,               product0_.width                 as width75_,               product0_.height                as height75_,               product0_.contractPurchasePrice as contrac78_75_,               product0_.taxrate               as taxrate75_,               product0_.isSent                as isSent75_,               product0_.process               as process75_,               product0_.sentTime              as sentTime75_,               product0_.receiveTime           as receive83_75_,               product0_.picPath               as picPath75_,               product0_.isNotStock            as isNotStock75_,               product0_.joinFanli             as joinFanli75_,               product0_.commentCount          as comment87_75_,               product0_.satisfactionScore     as satisfa88_75_,               product0_.fanliPrice            as fanliPrice75_,               product0_.level_                as level90_75_          from HOMEVV_PRODUCT product0_         where product0_.vvshop = 1           and product0_.commend = 1           and (product0_.ID in               (select v.productId                   from (                   (select distinct recommondp1_.productId,                                          recommondp1_.recommendNum                            from HOMEVV_RECOMMOND_PRO_TYPE recommondp1_                           where (recommondp1_.recommondType in ('index'))                             and recommondp1_.warehouse =                                 'ff808081316003c60131606ef17127d8'                           order by recommondp1_.recommendNum desc)                           ) v                           )                           )) where rownum <= 10;
  相关解决方案