@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()
Query
getResultList
in interface Query
getResultList
in interface TypedQuery<T>
public T getSingleResult()
Query
getSingleResult
in interface Query
getSingleResult
in interface TypedQuery<T>
@Nullable public T getFirstResult()
Query
getFirstResult
in interface Query
getFirstResult
in interface TypedQuery<T>
public int executeUpdate()
Query
executeUpdate
in interface Query
public TypedQuery<T> setMaxResults(int maxResults)
Query
setMaxResults
in interface Query
setMaxResults
in interface TypedQuery<T>
public TypedQuery<T> setFirstResult(int firstResult)
Query
setFirstResult
in interface Query
setFirstResult
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 Query
setParameter
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 Query
setParameter
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 Query
setParameter
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 Query
setParameter
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 Query
setParameter
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 Query
setParameter
in interface TypedQuery<T>
position
- parameter position, starting with 1value
- parameter valuetemporalType
- type of Date valuepublic TypedQuery<T> setLockMode(javax.persistence.LockModeType lockMode)
Query
setLockMode
in interface Query
setLockMode
in interface TypedQuery<T>
lockMode
- lock modepublic TypedQuery<T> setView(io.jmix.core.FetchPlan fetchPlan)
Query
setView
in interface Query
setView
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)
TypedQuery
setViewName
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)
Query
setView
in interface Query
setView
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)
Query
addView
in interface Query
addView
in interface TypedQuery<T>
fetchPlan
- view instance - must not be nullpublic TypedQuery<T> addViewName(java.lang.String fetchPlanName)
TypedQuery
addViewName
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)
Query
addView
in interface Query
addView
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 Query
public java.lang.String getQueryString()
Query
getQueryString
in interface Query
public TypedQuery<T> setQueryString(java.lang.String queryString)
Query
setQueryString
in interface Query
queryString
- query stringpublic TypedQuery<T> setCacheable(boolean cacheable)
TypedQuery
setCacheable
in interface Query
setCacheable
in interface TypedQuery<T>
cacheable
- whether query is cacheablepublic TypedQuery<T> setFlushMode(javax.persistence.FlushModeType flushMode)
TypedQuery
setFlushMode
in interface Query
setFlushMode
in interface TypedQuery<T>
flushMode
- flush modepublic TypedQuery<T> setHint(java.lang.String hintName, java.lang.Object value)
Query
setHint
in interface Query
hintName
- name of property or hintvalue
- value of the property or hintQueryHints
public void setSingleResultExpected(boolean singleResultExpected)