A parameterized query is a Repository Query that is incomplete (that is, missing some data) when it is created, and is supplied with that data when the query is executed. This is very similar to a PreparedStatement in JDBC. Parameterized queries are supported only in the SQL repository. You can substitute a parameter only for constant values, and not column specifications in a Repository Query. The use of parameters in a Query enables developers to reuse a single instance of that Query over and over again, supplying different parameter values at execution time. For example, if your goal is to create a Query like this:

select id from dps_user where first_name = 'keith'

only the value 'keith' can be parameterized; the column name first_name cannot. Sorting and range information also cannot be parameterized, so only constraints can use parameters. Furthermore, parameterized queries are used only in queries against the database; you cannot use parameterized queries against transient properties or in cases where the SQL Repository component’s useDatabaseQueries property is set to false.

loading table of contents...