我hibernate的配置文件里有两个many-to-one如下    <many-to-one name="tpListOption" class="com.easecom.base.model.ListOptions" fetch="select" lazy="false">
         <column name="type" length="32"></column>
        </many-to-one>
        <many-to-one name="stListOption" class="com.easecom.base.model.ListOptions" fetch="select" lazy="false">
         <column name="state" length="32"></column>
        </many-to-one>这两个实体类其实是一个,是我项目中的数据字典
我现在想问下,两个many-to-one的hql语句怎么写?
我这样写的
String hq =  "from Assets Assets left outer join Assets.stListOption s," +
left outer join Assets.tpListOption t"+
" where 1=1 "但是不对,应该怎么写呢?

解决方案 »

  1.   

    错误如下unexpected token: left near line 1, column 83 [from com.easecom.assets.model.Assets Assets left outer join Assets.stListOption s,left outer join Assets.tpListOption t where 1=1  order by Assets.cgDate Desc]
      

  2.   

    就是一个查询的hql语句怎么写
      

  3.   

    Assets,stListOption,tpListOption三者是什么关系 
      

  4.   

    首先 我不知道你想要做什么  但先提醒你一点  很多人都感觉 HQL不需要些  select X from  其实 这是错误的   不写的都是新手的表现  鉴于HIBERNATE 的关联查询性能  最好是写上  并不要一味的查询对象  最好是需要什么查询什么  这样能大大的提高程序的性能
     2 :  你想查什么??  请把实体发出来 你需要查的东西发出来
      

  5.   


    String hq =  "from Assets a where a.stListOption.xxx = " + xxx + " and a.tpListOption.xxx= " + xxx;