2009-02-25 5 views

risposta

36

Non ho trovato alcuna specifica del comportamento nei documenti di Hibernate, ma l'operatore between in HQL è tradotto nell'operatore between in SQL, che è inclusivo.

Così between in HQL è anche compreso, cioè

A between 5 and 10 

è equivalente a

A >= 5 and A <= 10 
+1

Ecco le specifiche sulla JPQL tra: http://docs.oracle.com/cd/E17904_01 /apirefs.1111/e13946/ejb3_langref.html#ejb3_langref_between – gerrytan

2

ovviamente, v'è una certa confusione per quanto riguarda questo. il linguaggio naturale suggerirebbe che fosse esclusivo, ma questo non è vero. in realtà è A> = 5 e A < = 10. dal momento che ci sono già state in contraddizione con risposte date (e delted), ci deve essere maggiori chiarimenti: (da 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; 
Problemi correlati