Null value semantics

The following describe the semantics of NULL values:

  • Comparison or arithmetic operations with an unknown (NULL) value yield an unknown value

  • In a Java 2 platform, Enterprise Edition (J2EE) version 1.3 application, a path expression uses an outer-join semantic where a NULL field or cmr value evaluates to NULL. In J2EE version 1.4, the path expression uses an inner-join semantic.

  • The IS NULL and IS NOT NULL operators can be applied to path expressions and return TRUE or FALSE. Boolean operators AND, OR and NOT use three valued logic.

AND True False Unknown
True True False Unknown
False False False False
Unknown Unknown False Unknown

OR True False Unknown
True True True True
False True False Unknown
Unknown True Unknown Unknown

  NOT
True False
False True
Unknown Unknown

 

Example: Null value semantics

select object(e) from EmpBean where e.salary > 10  and e.dept.budget > 100

If salary is NULL the evaluation of e.salary > 10 returns unknown and the employee object is not returned. If the cmr field dept or budget is NULL evaluation of e.dept.budget > 100 returns unknown and the employee object is not returned.

select object(e) from EmpBean where e.dept.budget is null

In J2EE 1.3 if dept or budget is NULL evaluation of e.dept.budget is null returns TRUE and the employee object is returned. In J2EE 1.4 the employee object is returned only if budget is NULL.

select object(e) from EmpBean e ,  in (e.dept.emps) e1 where e1.salary > 10

If dept is NULL, then the multivalued path expression e.dept.emps results in an empty collection (not a collection that contains a NULL value). An employee with a null dept value will not be returned.

select object(e) from EmpBean e where  e.dept.emps is empty

If dept is NULL the evaluation of the predicate in unknown and the employee object is not returned.

select object(e) from EmpBean e , EmpBean e1  where e member of  e1.dept.emps

If dept is NULL evaluation of the member of predicate returns unknown and the employee is not returned.


 

See Also


EJB query language
WHERE clause
Expressions

 

Related Tasks


Using EJB query