问一下这个hql语句怎么写

哎呦喂哈 2012-04-28 10:07:16
我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 "

但是不对,应该怎么写呢?
...全文
135 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
哎呦喂哈 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

不明白想要实现什么
[/Quote]
就是一个查询的hql语句怎么写
zhou370370 2012-04-28
  • 打赏
  • 举报
回复
不明白想要实现什么
哎呦喂哈 2012-04-28
  • 打赏
  • 举报
回复
自己顶一下,怎么没人回答呢
哎呦喂哈 2012-04-28
  • 打赏
  • 举报
回复
错误如下

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]
VanBaston 2012-04-28
  • 打赏
  • 举报
回复

String hq = "from Assets a where a.stListOption.xxx = " + xxx + " and a.tpListOption.xxx= " + xxx;
chenhu87 2012-04-28
  • 打赏
  • 举报
回复
首先 我不知道你想要做什么 但先提醒你一点 很多人都感觉 HQL不需要些 select X from 其实 这是错误的 不写的都是新手的表现 鉴于HIBERNATE 的关联查询性能 最好是写上 并不要一味的查询对象 最好是需要什么查询什么 这样能大大的提高程序的性能
2 : 你想查什么?? 请把实体发出来 你需要查的东西发出来
程序员阿牛啊 2012-04-28
  • 打赏
  • 举报
回复
Assets,stListOption,tpListOption三者是什么关系


81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧