我现在需要写一个SQL String hql = "from TbArticle model where 1=1 ";
hql += "and model.subject.id = "+subjectId+" ";
hql += "and model.type = 2 ";
hql += "order by model.createTime desc";
持久化层用的是hibernate
数据库是oracle问题 现在的hql语句能查出所有的,但是我想用hql语句只查第一条,怎么写 怎么写 求帮助!
我试了一下 加 limit 1 但是知道肯定不行 这个mysql的 求帮助 在线等 有答案就结贴
hql += "and model.subject.id = "+subjectId+" ";
hql += "and model.type = 2 ";
hql += "order by model.createTime desc";
持久化层用的是hibernate
数据库是oracle问题 现在的hql语句能查出所有的,但是我想用hql语句只查第一条,怎么写 怎么写 求帮助!
我试了一下 加 limit 1 但是知道肯定不行 这个mysql的 求帮助 在线等 有答案就结贴
select * from
(select * from TbArticle model order by model.createTime desc)
where rownum<2
可是我要用hql语句啊 能改成hql语句吗?
hql += "and model.subject.id = "+subjectId+" ";
hql += "and model.type = 2 ";
hql += "order by model.createTime desc)";
hql += " where rownum<2";