HQL 中的 between 是不是严格比较?

Posted

技术标签:

【中文标题】HQL 中的 between 是不是严格比较?【英文标题】:Does between in HQL compare strictly or not?HQL 中的 between 是否严格比较? 【发布时间】:2010-10-09 19:43:21 【问题描述】:

如果我用 HQL 编写

A between 5 and 10

是否等同于

A >= 5 and A <= 10

A > 5 and A < 10

或其他 4 种组合?

【问题讨论】:

【参考方案1】:

我在 Hibernate 文档中没有找到任何行为规范,但是 HQL 中的 between 运算符被转换为 SQL 中的 between 运算符,这是包容性的。

所以HQL中的between也是包容的,即

A between 5 and 10

等价于

A >= 5 and A <= 10

【讨论】:

这里是关于 JPQL 的规范:docs.oracle.com/cd/E17904_01/apirefs.1111/e13946/… 注意:使用 AWS Glue 1 和 2,between 是专有的。它从 Glue 3 变为包容性。【参考方案2】:

显然,对此存在一些混淆。自然语言会暗示它是排他性的,但事实并非如此。实际上它的 A >= 5 和 Ahttp://www.techonthenet.com/sql/between.php

Example #1 - Numbers

The following is an SQL statement that uses the BETWEEN function:

SELECT *
FROM suppliers
WHERE supplier_id between 5000 AND 5010;

This would return all rows where the supplier_id is between 5000 and 5010, inclusive. It is equivalent to the following SQL statement:

SELECT *
FROM suppliers
WHERE supplier_id >= 5000
AND supplier_id <= 5010;

【讨论】:

以上是关于HQL 中的 between 是不是严格比较?的主要内容,如果未能解决你的问题,请参考以下文章

没有时间戳的 HQL 中的日期比较

论文笔记The Dilemma between Deduplication and Locality: Can Both be Achieved?

论文笔记The Dilemma between Deduplication and Locality: Can Both be Achieved?

论文笔记The Dilemma between Deduplication and Locality: Can Both be Achieved?

[Ray.Tune] [已解决] Queue objects should only be shared between processes through inheritance

[Ray.Tune] [已解决] Queue objects should only be shared between processes through inheritance