public class QueryBinder extends Object
Modifier and Type | Method and Description |
---|---|
QueryBinder |
bind(Map<String,Object> namedParams,
Object... params)
Bind the query with the given named and/or positional parameters.
|
QueryBinder |
bind(String name,
Object value)
Bind the given named parameter with the given value.
|
Query |
getQuery()
Get the underlying query instance.
|
static QueryBinder |
of(Query query)
Create a new query binder for the given query instance.
|
QueryBinder |
opts(boolean cacheable,
FlushModeType type)
Shortcut to the
setCacheable() and setFlushMode(FlushModeType) methods. |
QueryBinder |
setCacheable()
Set the query cacheable.
|
QueryBinder |
setCacheable(boolean cacheable)
Set whether to set the query cacheable or not.
|
QueryBinder |
setFlushMode(FlushModeType mode)
Set query flush mode.
|
QueryBinder |
setReadOnly()
Set the query readOnly.
|
QueryBinder |
setReadOnly(boolean readOnly)
Set the query readOnly.
|
public static QueryBinder of(Query query)
query
- the query instancepublic QueryBinder setCacheable()
public QueryBinder setCacheable(boolean cacheable)
cacheable
- whether to set cacheable or notpublic QueryBinder setReadOnly()
public QueryBinder setReadOnly(boolean readOnly)
This will give better performance if the result is not meant for updates. For example, REST api data fetching can benefit from this.
public QueryBinder setFlushMode(FlushModeType mode)
mode
- flush modepublic QueryBinder opts(boolean cacheable, FlushModeType type)
setCacheable()
and setFlushMode(FlushModeType)
methods.cacheable
- whether to mark the query cacheabletype
- the FlushModeType
, only set if type is not nullpublic QueryBinder bind(Map<String,Object> namedParams, Object... params)
The parameter values will be automatically adapted to correct data type of the query parameter.
namedParams
- the named parametersparams
- the positional parameterspublic QueryBinder bind(String name, Object value)
name
- the named parametervalue
- the parameter valuepublic Query getQuery()