选择下一个位置
是否可以将这个查询(来自 Postgres)表达为 HQL 或 Hibernate 标准查询?
SELECT id, least(abs(gene_start - ?) , abs(gene_end - ?)) as div_pos
FROM arraydata.gene WHERE chromosomeref = ?
ORDER BY div_s LIMIT 1
或者是否有其他方法来选择给定位置旁边的条目。表中一个条目的开头或结尾与查询的距离最小。
Is it possible to express this query (from Postgres) as in HQL or as a hibernate criteria query?
SELECT id, least(abs(gene_start - ?) , abs(gene_end - ?)) as div_pos
FROM arraydata.gene WHERE chromosomeref = ?
ORDER BY div_s LIMIT 1
Or is there a other way to select a entry there is next to a given position. Where the start or the end of one entry from the table has the smallest distance to the query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个东西:
根本不可索引。我想你有gene_start和gene_end的索引,所以你可以这样做:
你可以将两者与UNION结合起来。至于在 Hibernate 中表达它,不知道!
This stuff :
is not indexable at all. I suppose you got indexes on gene_start and gene_end, so you could do :
You can combine both with UNION. As for expressing it in Hibernate, no idea !