In all of the previous examples, the queries contain hard-coded constants, such as 30 or joe. Most of the time, the actual values used in the query are unknown at the time the RQL statement is written. In these cases, the values may be substituted with parameter expressions. For example:

age > ?0 AND firstName CONTAINS ?1 RANGE ?2+10

Every ?{number} represents a parameterized value that is filled in when the query is executed. How those values are supplied depends on the application performing the query. In the case of entity EJBs, where RQL queries are used to represent finder methods, the parameters are filled in from the arguments of the finder methods. For example, ?0 is substituted with the value of the first argument, ?1 with the second, and so on.

Parameter expressions can generally be used wherever constant values are used, including in RANGE expressions. However, parameter expressions may not be used in array expressions, such as ID IN or IN FOLDERS queries. Also, parameter expressions may not be used as substitutes for property names; all property names must be hard-coded into the RQL query when it is written.

loading table of contents...