Interface QueryPopulator
- All Known Implementing Classes:
QueryPopulatorImpl
public interface QueryPopulator
Attempts to ease adding parameters to a query that are often used and/or evaluated as late as possible (for example the current date).
This service will search the query string for named parameters. If it finds one that it knows the value for, it will set it in the query.
Example:
String qs = "find Date where relUser.pk == :currentUser"; DynamicQueryPopulator dargs = //inject via spring Query q = dargs.createAndPopulateQuery(qs, ctx); EntityList list = q.execut();
Please see the implementation class for how to configure this service. To know all known parameter names search the hivemodule.xml files for 'ArgumentFactory'.
-
Method Summary
Modifier and TypeMethodDescriptioncreateAndPopulateQuery
(String queryStr, Context context) CallspopulateQuery(Query, String, Context)
after compiling the query string into aQuery
object.Returns all parameter names that are known to this service.void
populateQuery
(Query q, FuncallNode qstr, Context context) void
populateQuery
(Query q, String qstr, Context context) Populates the given query according to the parameter names it recognizes.
-
Method Details
-
populateQuery
Populates the given query according to the parameter names it recognizes.
It searches the query string for any occurence of a registered named parameter and invokes
Query.setParameter(String, Object)
with the appropriate value.- Parameters:
q
- the compiled queryqstr
- the string used to compile the querycontext
- the persist context to use- Throws:
PersistException
-
populateQuery
- Throws:
PersistException
-
createAndPopulateQuery
CallspopulateQuery(Query, String, Context)
after compiling the query string into aQuery
object.- Parameters:
queryStr
- the query stringcontext
- the persist context to use- Returns:
- the compiled and populated query
- Throws:
PersistException
-
getRegisteredParameterNames
Returns all parameter names that are known to this service.
-