应该是能直接在里面写SQL的。
比如"from ***"这些改成你的sql,试试...

解决方案 »

  1.   

    Hibernate2明确不支持Union.
    在Hibernate In Action说到过.
    Hibernate3是否支持不得而知.
    对于复杂的Sql直接用Session.getConnection
    然后用JDBC的一套.
      

  2.   

    select ttp.sid,ttp.name, 
    tp.sid,tp.value from 
    (select * from task_template_property 
    where tas_sid=(select tas_sid from task where sid='1')) ttp 
    left join (select * from task_property where tas_sid='1') 
    tp on tp.tas_sid2=tp.sid 
    这样的SQL怎么翻译成HQL?
      

  3.   

    打错了,最后的条件应该是
    on tp.tas_sid2=ttp.sid
      

  4.   

    其中tp与ttp是多对一的关系,与task也是多对一的关系,用HQL能实现吗?
      

  5.   

    Hibernate3.0好象查询可以直接在里面直接写SQL语句的!不用HQL也可以!
      

  6.   

    回复人: wmm1977(吴明明) ( ) 信誉:100  2005-07-23 20:32:00  得分: 0  
     
     
       select ttp.sid,ttp.name, 
    tp.sid,tp.value from 
    (select * from task_template_property 
    where tas_sid=(select tas_sid from task where sid='1')) ttp 
    left join (select * from task_property where tas_sid='1') 
    tp on tp.tas_sid2=tp.sid 
    这样的SQL怎么翻译成HQL?
      
     
    这个太复杂了吧!
      

  7.   

    对于过于复杂的sql,或要求极高效率的查询,你应该使用jdbc或ibatis实现,如果你使用dao对hibernate进行了良好的封装,混用jdbc并不会让你的系统混乱的。
      

  8.   

    写得查询语句首先要数据库支持才行,另外根据楼主的问题,复杂的查询语句可以在配置文件中(*.hbm.xml)配置好查询语句,用的时候使用findbynamequery就可以.不知道楼主问得是不是这个意思
      

  9.   

    其实可以把sql写在xml的外边调用,改起来也方便。
    hibernate参考手册里有