The Java EE 6 Tutorial, Volume I

Equality Semantics

In the query language, only values of the same type can be compared. However, this rule has one exception: Exact and approximate numeric values can be compared. In such a comparison, the required type conversion adheres to the rules of Java numeric promotion.

The query language treats compared values as if they were Java types and not as if they represented types in the underlying data store. For example, if a persistent field could be either an integer or a NULL, then it must be designated as an Integer object and not as an int primitive. This designation is required because a Java object can be NULL but a primitive cannot.

Two strings are equal only if they contain the same sequence of characters. Trailing blanks are significant; for example, the strings ’abc’ and ’abc ’ are not equal.

Two entities of the same abstract schema type are equal only if their primary keys have the same value. Table 21–9 shows the operator logic of a negation, and Table 21–10 shows the truth values of conditional tests.

Table 21–9 NOT Operator Logic

NOT Value 


Table 21–10 Conditional Test

Conditional Test 

Expression IS TRUE

Expression IS FALSE

Expression is unknown