如果我用HQL编写
A between 5 and 10
相当于
A >= 5 and A <= 10
或
A > 5 and A < 10
或其他4种组合?
答案 0 :(得分:40)
我没有在Hibernate文档中找到任何行为规范,但是HQL中的between
运算符被转换为SQL中的between
运算符,这是包含的。
因此,HQL中的between
也是包容性的,即
A between 5 and 10
相当于
A >= 5 and A <= 10
答案 1 :(得分:3)
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;