Operating Systems: i5/OS
Personalize the table of contents and search results
EJB query compatibility issues with SQL
Because an Enterprise JavaBeans (EJB) query is compiled into structured
query language (SQL), be aware of compatibility issues
between the Java language and SQL.
The two languages differ along the following points that can be critical
to correct EJB query formulation:
- The comparison semantics of SQL strings do not exactly match those of
the Java language. For example: 'A' (the letter A) and'A ' (the
letter A plus a blank space) are considered equal in SQL, but not in the Java
language.
- Comparisons and collating order depend on the underlying database. For
example, if you are using DB2 with an EBCDIC code page, the collating order
is not the same as doing the sort in a Java program. Some databases sort the
NULL value low while others sort the NULL value high.
- An arithmetic overflow causes an exception in SQL, but not in the Java
language.
- SQL databases have differing minimum and maximum ranges for floating point
values, which can differ from floating point value ranges in the Java language.
Values near the range limits of Java Double may fail to translate into SQL.
- Java methods do not translate into SQL; therefore standard EJB queries
cannot include Java methods.
Note: Only with the dynamic EJB query service
can you use functions that do not translate into SQL. Such functions include
Java methods and converters or composers that are used in mapping enterprise
beans to relational databases (RDBs). A standard finder or select query that
uses any of these functions fails at deployment time with the message "Cannot
push down query". (You can resolve this problem by changing either the query
or the mapping.) The dynamic query run time, however, processes the query
by performing the operation involving the function in the application server.
Related concepts
EJB query language
Rules for data type manipulation in EJB query
Database restrictions for EJB query
Related tasks
Using EJB query