if I write in HQL
A between 5 and 10
is that equivalent to
A >= 5 and A <= 10
or
A > 5 and A < 10
or some other of the 4 combinations?
if I write in HQL
A between 5 and 10
is that equivalent to
A >= 5 and A <= 10
or
A > 5 and A < 10
or some other of the 4 combinations?
I didn't find any specification of the behavior in the Hibernate docs, but the between
operator in HQL is translated to the between
operator in SQL, which is inclusive.
So between
in HQL is also inclusive, that is
A between 5 and 10
is equivalent to
A >= 5 and A <= 10
obviously there is some confusion regarding this. natural language would suggest it is exclusive, but this is not true. in reality its A >= 5 and A<=10. since there were already contradicting answers given (and delted), there needs to be more clarification: (from 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;