Using the Built-In Functions

   

EJB QL provides a few built-in functions for performing some common string and arithmetic manipulations to build your queries. The functions that are supported are standard SQL operations that all JDBC 2.0 and higher drivers are required to support.

String Functions

EJB QL supports the following string manipulation functions:

  • CONCAT(String first, String second) concatenates its two arguments and returns the resulting String .

  • SUBSTRING(String source, int start, int length) returns a String that is a substring of its argument based on the specified starting index and requested string length.

  • LOCATE(String source, String pattern) returns an int value that defines the starting index within the source string that a pattern string is found.

  • LOCATE(String source, String pattern, int start) is an overloaded version of LOCATE that only looks at the portion of the source string starting with a specified index.

  • LENGTH(String source) returns an int value that reports the number of characters found in its string argument.

Arithmetic Functions

EJB QL supports the following arithmetic functions:

  • ABS(int number) returns the absolute value of an int argument as an int .

  • ABS(float number) returns the absolute value of a float argument as a float .

  • ABS(double number) returns the absolute value of a double argument as a double .

  • SQRT (double number) returns the square root of its argument as a double .

Currently, there's no support for aggregate functions, such as MIN and MAX , in EJB QL. That likely will be added in later versions of the specification. Until then, you're somewhat limited in what you can do in a select method.



Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net