2009-02-25 44 views

回答

36

我沒有在Hibernate文檔中找到任何行爲規範,但HQL中的between運算符被轉換爲SQL中的between運算符,這是包含性的。

所以between在HQL也是包容性,這是

A between 5 and 10 

相當於

A >= 5 and A <= 10 
+1

這裏的之間的JPQL規範:http://docs.oracle.com/cd/E17904_01 /apirefs.1111/e13946/ejb3_langref.html#ejb3_langref_between – gerrytan 2014-06-05 00:59:59

2

顯然是有這方面有些混亂。自然語言表明它是排他性的,但這不是事實。實際上它的A> = 5和A = < = 10。 因爲已經違背給出答案(和delted),需要有更多的澄清:(從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;