@Component(value="cuba_Query") @Scope(value="prototype") public class QueryImpl<T> extends java.lang.Object implements TypedQuery<T>
TypedQuery interface based on EclipseLink.| Constructor and Description |
|---|
QueryImpl(io.jmix.data.JmixQuery delegate) |
QueryImpl(io.jmix.data.JmixQuery delegate,
java.lang.Class resultClass) |
| Modifier and Type | Method and Description |
|---|---|
TypedQuery<T> |
addView(java.lang.Class<? extends io.jmix.core.Entity> entityClass,
java.lang.String fetchPlanName)
Adds View for this Query instance.
|
TypedQuery<T> |
addView(io.jmix.core.FetchPlan fetchPlan)
Adds View for this Query instance.
|
TypedQuery<T> |
addViewName(java.lang.String fetchPlanName)
Adds View for this Query instance.
|
int |
executeUpdate()
Execute an update or delete statement.
|
javax.persistence.Query |
getDelegate() |
T |
getFirstResult()
Execute a SELECT query.
Returns null if there is no result. Returns first result if more than one result. |
java.lang.String |
getQueryString()
Get the query string.
|
java.util.List<T> |
getResultList()
Execute a SELECT query and return the query results as a List.
|
T |
getSingleResult()
Execute a SELECT query that returns a single result.
|
TypedQuery<T> |
setCacheable(boolean cacheable)
Set query results to be cached
|
TypedQuery<T> |
setFirstResult(int firstResult)
Set the position of the first result to retrieve.
|
TypedQuery<T> |
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
TypedQuery<T> |
setHint(java.lang.String hintName,
java.lang.Object value)
Set a query property or hint.
|
TypedQuery<T> |
setLockMode(javax.persistence.LockModeType lockMode)
Set the lock mode type to be used for the query execution.
|
TypedQuery<T> |
setMaxResults(int maxResults)
Set the maximum number of results to retrieve.
|
TypedQuery<T> |
setParameter(int position,
java.util.Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a positional parameter.
|
TypedQuery<T> |
setParameter(int position,
java.lang.Object value)
Bind an argument to a positional parameter.
|
TypedQuery<T> |
setParameter(int position,
java.lang.Object value,
boolean implicitConversions)
Bind an argument to a positional parameter.
|
TypedQuery<T> |
setParameter(java.lang.String name,
java.util.Date value,
javax.persistence.TemporalType temporalType)
Bind an instance of java.util.Date to a named parameter.
|
TypedQuery<T> |
setParameter(java.lang.String name,
java.lang.Object value)
Bind an argument to a named parameter.
In the query text, named parameters are marked with colon (e.g. |
TypedQuery<T> |
setParameter(java.lang.String name,
java.lang.Object value,
boolean implicitConversions)
Bind an argument to a named parameter.
In the query text, named parameters are marked with colon (e.g. |
TypedQuery<T> |
setQueryString(java.lang.String queryString)
Set the query string.
|
void |
setSingleResultExpected(boolean singleResultExpected) |
TypedQuery<T> |
setView(java.lang.Class<? extends io.jmix.core.Entity> entityClass,
java.lang.String viewName)
Set View for this Query instance.
|
TypedQuery<T> |
setView(io.jmix.core.FetchPlan fetchPlan)
Set View for this Query instance.
|
TypedQuery<T> |
setViewName(java.lang.String fetchPlanName)
Set View for this Query instance.
|
public QueryImpl(io.jmix.data.JmixQuery delegate,
java.lang.Class resultClass)
public QueryImpl(io.jmix.data.JmixQuery delegate)
public java.util.List<T> getResultList()
QuerygetResultList in interface QuerygetResultList in interface TypedQuery<T>public T getSingleResult()
QuerygetSingleResult in interface QuerygetSingleResult in interface TypedQuery<T>@Nullable public T getFirstResult()
QuerygetFirstResult in interface QuerygetFirstResult in interface TypedQuery<T>public int executeUpdate()
QueryexecuteUpdate in interface Querypublic TypedQuery<T> setMaxResults(int maxResults)
QuerysetMaxResults in interface QuerysetMaxResults in interface TypedQuery<T>public TypedQuery<T> setFirstResult(int firstResult)
QuerysetFirstResult in interface QuerysetFirstResult in interface TypedQuery<T>firstResult - position of the first result, numbered from 0public TypedQuery<T> setParameter(java.lang.String name, java.lang.Object value)
Query:foo) in JPQL queries or with
number sign in native SQL queries (e.g. #foo).setParameter in interface QuerysetParameter in interface TypedQuery<T>name - parameter namevalue - parameter value. Entity instance replaced with its ID.public TypedQuery<T> setParameter(java.lang.String name, java.lang.Object value, boolean implicitConversions)
Query:foo) in JPQL queries or with
number sign in native SQL queries (e.g. #foo).setParameter in interface QuerysetParameter in interface TypedQuery<T>name - parameter namevalue - parameter valueimplicitConversions - whether to make parameter value conversions, e.g. convert an entity to its IDpublic TypedQuery<T> setParameter(java.lang.String name, java.util.Date value, javax.persistence.TemporalType temporalType)
Query
In the query text, named parameters are marked with colon (e.g. :foo) in JPQL queries or with
number sign in native SQL queries (e.g. #foo).
setParameter in interface QuerysetParameter in interface TypedQuery<T>name - parameter namevalue - parameter valuetemporalType - type of Date valuepublic TypedQuery<T> setParameter(int position, java.lang.Object value)
Query
In the query text, positional parameters are marked with ?N (e.g. ?1).
setParameter in interface QuerysetParameter in interface TypedQuery<T>position - parameter position, starting with 1value - parameter value. Entity instance replaced with its ID.public TypedQuery<T> setParameter(int position, java.lang.Object value, boolean implicitConversions)
Query
In the query text, positional parameters are marked with ?N (e.g. ?1).
setParameter in interface QuerysetParameter in interface TypedQuery<T>position - parameter position, starting with 1value - parameter valueimplicitConversions - whether to make parameter value conversions, e.g. convert an entity to its IDpublic TypedQuery<T> setParameter(int position, java.util.Date value, javax.persistence.TemporalType temporalType)
Query?1).setParameter in interface QuerysetParameter in interface TypedQuery<T>position - parameter position, starting with 1value - parameter valuetemporalType - type of Date valuepublic TypedQuery<T> setLockMode(javax.persistence.LockModeType lockMode)
QuerysetLockMode in interface QuerysetLockMode in interface TypedQuery<T>lockMode - lock modepublic TypedQuery<T> setView(io.jmix.core.FetchPlan fetchPlan)
QuerysetView in interface QuerysetView in interface TypedQuery<T>fetchPlan - view instance. If null, eager fetching is performed according to JPA mappings.public TypedQuery<T> setViewName(java.lang.String fetchPlanName)
TypedQuerysetViewName in interface TypedQuery<T>fetchPlanName - view name - must not be nullpublic TypedQuery<T> setView(java.lang.Class<? extends io.jmix.core.Entity> entityClass, java.lang.String viewName)
QuerysetView in interface QuerysetView in interface TypedQuery<T>entityClass - entity class to get a view instance by the name providedviewName - view namepublic TypedQuery<T> addView(io.jmix.core.FetchPlan fetchPlan)
QueryaddView in interface QueryaddView in interface TypedQuery<T>fetchPlan - view instance - must not be nullpublic TypedQuery<T> addViewName(java.lang.String fetchPlanName)
TypedQueryaddViewName in interface TypedQuery<T>fetchPlanName - view name - must not be nullpublic TypedQuery<T> addView(java.lang.Class<? extends io.jmix.core.Entity> entityClass, java.lang.String fetchPlanName)
QueryaddView in interface QueryaddView in interface TypedQuery<T>entityClass - entity class to get a view instance by the name providedfetchPlanName - view name - must not be nullpublic javax.persistence.Query getDelegate()
getDelegate in interface Querypublic java.lang.String getQueryString()
QuerygetQueryString in interface Querypublic TypedQuery<T> setQueryString(java.lang.String queryString)
QuerysetQueryString in interface QueryqueryString - query stringpublic TypedQuery<T> setCacheable(boolean cacheable)
TypedQuerysetCacheable in interface QuerysetCacheable in interface TypedQuery<T>cacheable - whether query is cacheablepublic TypedQuery<T> setFlushMode(javax.persistence.FlushModeType flushMode)
TypedQuerysetFlushMode in interface QuerysetFlushMode in interface TypedQuery<T>flushMode - flush modepublic TypedQuery<T> setHint(java.lang.String hintName, java.lang.Object value)
QuerysetHint in interface QueryhintName - name of property or hintvalue - value of the property or hintQueryHintspublic void setSingleResultExpected(boolean singleResultExpected)