Package com.axelor.db
Class QueryBinder
java.lang.Object
com.axelor.db.QueryBinder
The query binder class provides the helper methods to bind query parameters and mark the query
cacheable.
-
Method Summary
Modifier and TypeMethodDescriptionBind the given named parameter with the given value.Bind the query with the given named and/or positional parameters.jakarta.persistence.Query
getQuery()
Get the underlying query instance.static QueryBinder
of
(jakarta.persistence.Query query) Create a new query binder for the given query instance.opts
(boolean cacheable, jakarta.persistence.FlushModeType type) Shortcut to thesetCacheable()
andsetFlushMode(FlushModeType)
methods.Set the query cacheable.setCacheable
(boolean cacheable) Set whether to set the query cacheable or not.setFlushMode
(jakarta.persistence.FlushModeType mode) Set query flush mode.Set the query readOnly.setReadOnly
(boolean readOnly) Set the query readOnly.
-
Method Details
-
of
Create a new query binder for the given query instance.- Parameters:
query
- the query instance- Returns:
- a new query binder instance
-
setCacheable
Set the query cacheable.- Returns:
- the same query binder instance
-
setCacheable
Set whether to set the query cacheable or not.- Parameters:
cacheable
- whether to set cacheable or not- Returns:
- the same query binder instance
-
setReadOnly
Set the query readOnly.- Returns:
- the same query binder instance
-
setReadOnly
Set the query readOnly.This will give better performance if the result is not meant for updates. For example, REST api data fetching can benefit from this.
- Returns:
- the same query binder instance
-
setFlushMode
Set query flush mode.- Parameters:
mode
- flush mode- Returns:
- the same query binder instance
-
opts
Shortcut to thesetCacheable()
andsetFlushMode(FlushModeType)
methods.- Parameters:
cacheable
- whether to mark the query cacheabletype
- theFlushModeType
, only set if type is not null- Returns:
- the same query binder instance
-
bind
Bind the query with the given named and/or positional parameters.The parameter values will be automatically adapted to correct data type of the query parameter.
- Parameters:
namedParams
- the named parametersparams
- the positional parameters- Returns:
- the same query binder instance
-
bind
Bind the given named parameter with the given value.- Parameters:
name
- the named parametervalue
- the parameter value- Returns:
- the same query binder instance
-
getQuery
public jakarta.persistence.Query getQuery()Get the underlying query instance.- Returns:
- the query instance
-