select * from cst_inf as ci inner join (select * from crcrd_bsc_inf as cbi where cbi.MAINCRD_CRDID like '%123%')  as  c  on c.CST_ID=ci.CST_ID;上述的sql语句如何转换成HQl语句,上述sql已经跑通了....恳请高人指点

解决方案 »

  1.   

    cst_inf  对象 CstInf
    crcrd_bsc_inf 对象 CrcrdBscInfhsql="
    select * from CstInf a ,CrcrdBscInf b
    where a.CSTID=b.CSTID and b.MAINCRDCRDID like ?"
     list = getHibernateTemplate().find(hsql, '%' + 123+ '%');
    123为变量
      

  2.   

    或者使用criteria 关联查询查询
      

  3.   

    select * from cst_inf as ci inner join (select * from crcrd_bsc_inf as cbi where cbi.MAINCRD_CRDID like '%123%')  as  c  on c.CST_ID=ci.CST_ID; 类 cst_inf和类crcrd_bsc_inf 并且cst_inf类中有crcrd_bsc_inf对象hql语句为:
    from cst_inf ci join fetch ci.crcrd_bsc_inf bsc where bsc.MAINCRD_CRDID like '%123%'
      

  4.   

    from cst_inf ci join fetch ci.crcrd_bsc_inf bsc where bsc.MAINCRD_CRDID like '%123%'
      

  5.   

    select ci , cbi from cst_inf as ci ,crcrd_bsc_inf as cbi 
    where  on cbi.CST_ID=ci.CST_ID
    and cbi.MAINCRD_CRDID like '%123%'
    因为你是iner join 
      

  6.   

    select * from cst_inf where cst_id in (select cst_id from crcrd_bsc_inf where maincrd_crdid like '%123%')