在HQL之间是否严格比较?

fly*_*ire 32 java hibernate jpa hql

如果我用HQL编写

A between 5 and 10
Run Code Online (Sandbox Code Playgroud)

相当于

A >= 5 and A <= 10
Run Code Online (Sandbox Code Playgroud)

要么

A > 5 and A < 10
Run Code Online (Sandbox Code Playgroud)

或者其他4种组合?

Dan*_*dei 40

我没有在Hibernate文档中找到任何行为规范,但是betweenHQL中的运算符被转换为betweenSQL中的运算符,这是包含的.

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

A between 5 and 10
Run Code Online (Sandbox Code Playgroud)

相当于

A >= 5 and A <= 10
Run Code Online (Sandbox Code Playgroud)

  • 这是 JPQL 之间的规范:http://docs.oracle.com/cd/E17904_01/apirefs.1111/e13946/ejb3_langref.html#ejb3_langref_between (2认同)

And*_*son 5

显然,对此存在一些困惑。自然语言表明它是排他性的,但事实并非如此。实际上它的 A >= 5 且 A<=10。由于已经给出了相互矛盾的答案(并删除了),因此需要更多澄清:(来自http://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;
Run Code Online (Sandbox Code Playgroud)