sql转hql请教,小妹不胜感激

yanfei_nn 2012-08-03 05:13:07
select t.*, count(r.type_id) as all_type_number from
(
select
doc.doc_id, doc_name, doc_time, count(doc.doc_id) as doc_number
from document doc
inner join r_doc_type r
on doc.doc_id = r.doc_id
where type_id in (3, 4)
group by doc.doc_id
) as t
inner join r_doc_type r
on t.doc_id = r.doc_id
group by t.doc_id
order by doc_number desc, all_type_number, doc_time desc



表结构如下:

1. r_doc_type





2. document





3. type





type 和document是多对多关系、但是数据库中没有建立关系。

现在想将这句sql转换为hql,求大哥帮忙,小妹不胜感激
...全文
330 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanfei_nn 2013-01-19
  • 打赏
  • 举报
回复
引用 8 楼 haiercs 的回复:
楼主,你的sql难道可以运行吗? select doc.doc_id, doc_name, doc_time, count(doc.doc_id) as doc_number from document doc inner join r_doc_type r on doc.doc_id = r.doc_id where ty……
MySQL里面是没有问题的
haiercs 2012-08-06
  • 打赏
  • 举报
回复
楼主,你的sql难道可以运行吗?
select
doc.doc_id, doc_name, doc_time, count(doc.doc_id) as doc_number
from document doc
inner join r_doc_type r
on doc.doc_id = r.doc_id
where type_id in (3, 4)
group by doc.doc_id
yanfei_nn 2012-08-05
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

呵呵,sql转换Hql语句 我认为就是访问的表转换成实体类,里面的列转换成实体类的属性
[/Quote]

要有那么简单就好了
oodick 2012-08-04
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
你很无聊
我更无聊

yanfei_nn: ”不是哥打击你、你实在不应该问这样的问题“
还小妹。。。
http://topic.csdn.net/u/20120516/20/e8a22ff9-4b38-497c-9f61-1b69840f348f.html?seed=728894556&r=78644809#r_78644809
[/Quote]

  • 打赏
  • 举报
回复
呵呵,sql转换Hql语句 我认为就是访问的表转换成实体类,里面的列转换成实体类的属性
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

你很无聊
我更无聊

yanfei_nn: ”不是哥打击你、你实在不应该问这样的问题“
还小妹。。。
http://topic.csdn.net/u/20120516/20/e8a22ff9-4b38-497c-9f61-1b69840f348f.html?seed=728894556&r=78644809#r_78644809
[/Quote]
believefym 2012-08-03
  • 打赏
  • 举报
回复
你很无聊
我更无聊

yanfei_nn: ”不是哥打击你、你实在不应该问这样的问题“
还小妹。。。
http://topic.csdn.net/u/20120516/20/e8a22ff9-4b38-497c-9f61-1b69840f348f.html?seed=728894556&r=78644809#r_78644809
yanfei_nn 2012-08-03
  • 打赏
  • 举报
回复
http://zhidao.baidu.com/question/459450462.html?quesup2

看不到图片了,这里有哇,急急急
yanfei_nn 2012-08-03
  • 打赏
  • 举报
回复
http://zhidao.baidu.com/question/459450462.html?quesup2

看不到图片了,这里有哇,急急急

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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