博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hibernate 随机 查询
阅读量:2453 次
发布时间:2019-05-10

本文共 854 字,大约阅读时间需要 2 分钟。

/**	 * 随机取出N条记录	 * 	 * @param filetype	 * @param position	 * @param dialog_box_type	 * @param total	 *            记录总数	 * @param count	 *            要取出几条	 * @return	 */	@Override	public List
getAdvs(String filetype, String position, String dialog_box_type, int total, int count) { String hql = "from Adv as adv where adv.id is not null "; if (StringUtils.isNotBlank(filetype)) { hql += " and adv.filetype ='" + filetype + "' "; } if (StringUtils.isNotBlank(position)) { hql += " and adv.position ='" + position + "' "; } if (StringUtils.isNotBlank(dialog_box_type)) { hql += " and adv.type.id ='" + dialog_box_type + "' "; } int first = total - count; first = first >= 0 ? first : 0; first = (int) Math.floor(Math.random() * first); return getSession().createQuery(hql).setFirstResult(first) .setMaxResults(count).list(); }
 

转载地址:http://fzdhb.baihongyu.com/

你可能感兴趣的文章
ci /cd_顶级CI / CD资源,助您成功
查看>>
k8s helm3.0_Helm 3.0,Vitess和Jaeger毕业以及来自KubeCon 2019的其他新闻
查看>>
opensource项目_宣布Opensource.com通讯程序
查看>>
eclipse ide使用_开始使用Eclipse Che IDE在云端进行开发
查看>>
coreboot_System76推出具有开源BIOS coreboot的笔记本电脑
查看>>
linux 备忘软件_常用Linux命令备忘单
查看>>
rust游戏是什么编程语言_为什么选择Rust作为您的下一种编程语言
查看>>
linux 备忘软件_Linux用户和权限备忘单
查看>>
客户要求开放接口_开放社区教我们如何增强客户能力
查看>>
和平友善敬业民主和平_合作如何推动绿色和平组织的发展突破
查看>>
容器 发展趋势_容器现实检查和更多行业趋势
查看>>
如何在开源社区贡献代码_在Hacktoberfest期间为开源做出贡献的5种方法
查看>>
cantata测试工具_我如何构建和维护开源音乐播放器Cantata
查看>>
如何在Java中比较字符串
查看>>
Bash外壳的诞生
查看>>
采用自上而下的语法分析中_为什么是时候采用自上而下的网络安全实践
查看>>
人工智能 lisp_与机器对话:Lisp和AI的起源
查看>>
rust 所有权_对其进行编码,运输,拥有完整服务所有权
查看>>
Linux Plumbers,Appwrite和更多行业趋势
查看>>
罗马复兴开源代码_社区主导的开源复兴
查看>>