public class JDOTypesafeQuery<T> extends AbstractTypesafeQuery<T> implements TypesafeQuery<T>
Modifier and Type | Field and Description |
---|---|
protected Collection<T> |
candidates |
protected Map<String,Object> |
extensions
Any extensions
|
protected Set<org.datanucleus.store.query.Query> |
internalQueries
Internal queries generated by this typesafe query.
|
protected Map<String,ExpressionImpl> |
parameterExprByName
Map of parameter expression keyed by the name.
|
protected Map<String,Object> |
parameterValuesByName
Map of parameters keyed by their name/expression.
|
protected ExpressionImpl |
rangeLowerExpr
Range : lower limit expression.
|
protected ExpressionImpl |
rangeUpperExpr
Range : upper limit expression.
|
protected Set<JDOTypesafeSubquery> |
subqueries
Set of any subqueries used by this query.
|
candidateAlias, candidateCls, ec, filter, grouping, having, ordering, pm, result, resultDistinct, type, updateExprs, updateVals
QUERY_CLASS_PREFIX
Constructor and Description |
---|
JDOTypesafeQuery(javax.jdo.PersistenceManager pm,
Class<T> candidateClass)
Constructor for a typesafe query.
|
Modifier and Type | Method and Description |
---|---|
TypesafeQuery |
addExtension(String key,
Object value)
Add a vendor-specific extension to this query.
|
PersistableExpression |
candidate()
Method to return an expression for the candidate of the query.
|
CharacterExpression |
characterParameter(String name)
Method to return a character parameter for the query.
|
void |
close(Object result)
Method to close the specified query result.
|
void |
closeAll()
Method to close all query results from this query.
|
CollectionExpression |
collectionParameter(String name)
Method to return a collection parameter for the query.
|
org.datanucleus.query.compiler.QueryCompilation |
compile(org.datanucleus.metadata.MetaDataManager mmgr,
org.datanucleus.ClassLoaderResolver clr)
Method to compile the typesafe query.
|
DateExpression<Date> |
dateParameter(String name)
Method to return a date parameter for the query.
|
DateTimeExpression<Date> |
datetimeParameter(String name)
Method to return a datetime parameter for the query.
|
long |
delete()
Extension method to provide bulk delete capabilities (not part of JDO).
|
long |
deletePersistentAll()
Method to execute the query deleting the affected instances.
|
protected void |
discardCompiled()
Called when something is set on the query making any compilation invalid.
|
NumericExpression<Double> |
doubleParameter(String name)
Method to return a numeric parameter for the query.
|
TypesafeQuery<T> |
excludeSubclasses()
Method to remove subclasses (of the candidate) from the query
|
protected Object |
executeInternalQuery(org.datanucleus.store.query.Query internalQuery) |
<T> List<T> |
executeList()
Method to execute the query where there are (potentially) multiple rows and we are returning
the candidate type.
|
List<Object[]> |
executeResultList(boolean distinct,
Expression... exprs)
Method to execute the query where there are (potentially) multiple rows and we have a result defined
but no result class.
|
List<Object> |
executeResultList(boolean distinct,
Expression expr)
Method to execute the query where there are (potentially) multiple rows and we have a single result defined
but no result class.
|
<R> List<R> |
executeResultList(Class<R> resultCls,
boolean distinct,
Expression... exprs)
Method to execute the query where there are (potentially) multiple rows and we are returning either a
result type or the candidate type.
|
Object[] |
executeResultUnique(boolean distinct,
Expression... exprs)
Method to execute the query where there is a single row and we have a result defined
but no result class.
|
Object |
executeResultUnique(boolean distinct,
Expression expr)
Method to execute the query where there is a single row and we have a single result defined
but no result class.
|
<R> R |
executeResultUnique(Class<R> resultCls,
boolean distinct,
Expression... exprs)
Method to execute the query where there is a single row and we are returning either a result type
or the candidate type.
|
<T> T |
executeUnique()
Method to execute the query where there is a single row and we are returning the candidate type.
|
TypesafeQuery<T> |
filter(BooleanExpression expr)
Method to set the filter of the query.
|
NumericExpression<Float> |
floatParameter(String name)
Method to return a numeric parameter for the query.
|
javax.jdo.FetchPlan |
getFetchPlan()
Accessor for the FetchPlan for this query
|
protected org.datanucleus.store.query.Query |
getInternalQuery()
Convenience method to generate an internal DataNucleus Query and apply the generic compilation to it.
|
javax.jdo.PersistenceManager |
getPersistenceManager()
Accessor for the PersistenceManager for this query
|
static String |
getQueryClassNameForClassName(String name)
Method to return the (simple) name of the query class for a specified class name.
|
TypesafeQuery<T> |
groupBy(Expression... exprs)
Method to set the grouping(s) for the query.
|
TypesafeQuery<T> |
having(Expression expr)
Method to set the having clause of the query.
|
TypesafeQuery<T> |
includeSubclasses()
Method to include subclasses (of the candidate) to the query
|
NumericExpression<Integer> |
integerParameter(String name)
Method to return a numeric parameter for the query.
|
ListExpression |
listParameter(String name)
Method to return a list parameter for the query.
|
NumericExpression<Long> |
longParameter(String name)
Method to return a numeric parameter for the query.
|
MapExpression |
mapParameter(String name)
Method to return a map parameter for the query.
|
TypesafeQuery<T> |
orderBy(OrderExpression... exprs)
Method to set the ordering of the query.
|
Expression |
parameter(String name,
Class type)
Method to return a parameter for the query.
|
TypesafeQuery<T> |
range(Expression paramLowerInclExpr,
Expression paramUpperExclExpr)
Method to set the range of any required results, using parameters (expressions).
|
TypesafeQuery<T> |
range(long lowerIncl,
long upperExcl)
Method to set the range of any required results, using long values.
|
TypesafeQuery<T> |
range(NumericExpression lowerInclExpr,
NumericExpression upperExclExpr)
Method to set the range of any required results, using expressions.
|
TypesafeQuery<T> |
set(Expression expr,
Object val)
Method to specify the update of a field of the candidate.
|
TypesafeQuery<T> |
setCandidates(Collection<T> candidates)
Method to set the candidates to use over which we are querying.
|
TypesafeQuery |
setExtensions(Map<String,Object> extensions)
Set multiple extensions, or use null to clear all extensions.
|
TypesafeQuery |
setIgnoreCache(boolean ignore)
Whether the query should ignore the cache and go straight to the datastore.
|
TypesafeQuery<T> |
setParameter(Expression paramExpr,
Object value)
Method to set a parameter value for use when executing the query.
|
TypesafeQuery<T> |
setParameter(String paramName,
Object value)
Method to set a parameter value for use when executing the query.
|
NumericExpression<Short> |
shortParameter(String name)
Method to return a numeric parameter for the query.
|
StringExpression |
stringParameter(String name)
Method to return a string parameter for the query.
|
<S> TypesafeSubquery<S> |
subquery(Class<S> candidateClass,
String candidateAlias)
Method to return a subquery for use in this query.
|
TypesafeSubquery<T> |
subquery(String candidateAlias)
Method to return a subquery for use in this query using the same candidate class as this query.
|
TimeExpression<Time> |
timeParameter(String name)
Method to return a time parameter for the query.
|
String |
toString()
Method to return the single-string form of this JDOQL query.
|
long |
update()
Extension method to provide bulk update capabilities (not part of JDO).
|
Expression |
variable(String name,
Class type)
Method to return a variable for this query.
|
getCompilation
protected Collection<T> candidates
protected ExpressionImpl rangeLowerExpr
protected ExpressionImpl rangeUpperExpr
protected Map<String,ExpressionImpl> parameterExprByName
protected Map<String,Object> parameterValuesByName
protected transient Set<JDOTypesafeSubquery> subqueries
protected transient Set<org.datanucleus.store.query.Query> internalQueries
public PersistableExpression candidate()
TypesafeQuery
candidate
in interface TypesafeQuery<T>
public Expression parameter(String name, Class type)
TypesafeQuery
parameter
in interface TypesafeQuery<T>
name
- Name of the parametertype
- Java type of the parameterpublic StringExpression stringParameter(String name)
TypesafeQuery
stringParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic CharacterExpression characterParameter(String name)
TypesafeQuery
characterParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic NumericExpression<Long> longParameter(String name)
TypesafeQuery
longParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic NumericExpression<Integer> integerParameter(String name)
TypesafeQuery
integerParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic NumericExpression<Short> shortParameter(String name)
TypesafeQuery
shortParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic NumericExpression<Double> doubleParameter(String name)
TypesafeQuery
doubleParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic NumericExpression<Float> floatParameter(String name)
TypesafeQuery
floatParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic DateExpression<Date> dateParameter(String name)
TypesafeQuery
dateParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic TimeExpression<Time> timeParameter(String name)
TypesafeQuery
timeParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic DateTimeExpression<Date> datetimeParameter(String name)
TypesafeQuery
datetimeParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic CollectionExpression collectionParameter(String name)
TypesafeQuery
collectionParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic MapExpression mapParameter(String name)
TypesafeQuery
mapParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic ListExpression listParameter(String name)
TypesafeQuery
listParameter
in interface TypesafeQuery<T>
name
- Name of the parameterpublic Expression variable(String name, Class type)
TypesafeQuery
variable
in interface TypesafeQuery<T>
name
- Name of the variabletype
- Type of the variablepublic TypesafeQuery<T> excludeSubclasses()
TypesafeQuery
excludeSubclasses
in interface TypesafeQuery<T>
public TypesafeQuery<T> includeSubclasses()
TypesafeQuery
includeSubclasses
in interface TypesafeQuery<T>
public TypesafeQuery<T> filter(BooleanExpression expr)
TypesafeQuery
filter
in interface TypesafeQuery<T>
expr
- Filter expressionpublic TypesafeQuery<T> groupBy(Expression... exprs)
TypesafeQuery
groupBy
in interface TypesafeQuery<T>
exprs
- Grouping expression(s)public TypesafeQuery<T> having(Expression expr)
TypesafeQuery
having
in interface TypesafeQuery<T>
expr
- Having expressionpublic TypesafeQuery<T> orderBy(OrderExpression... exprs)
TypesafeQuery
orderBy
in interface TypesafeQuery<T>
exprs
- Ordering expression(s)public TypesafeQuery<T> range(long lowerIncl, long upperExcl)
TypesafeQuery
range
in interface TypesafeQuery<T>
lowerIncl
- The position of the first result (inclusive)upperExcl
- The position of the last result (exclusive)public TypesafeQuery<T> range(NumericExpression lowerInclExpr, NumericExpression upperExclExpr)
TypesafeQuery
range
in interface TypesafeQuery<T>
lowerInclExpr
- The position of the first result (inclusive)upperExclExpr
- The position of the last result (exclusive)public TypesafeQuery<T> range(Expression paramLowerInclExpr, Expression paramUpperExclExpr)
TypesafeQuery
range
in interface TypesafeQuery<T>
paramLowerInclExpr
- Expression for a parameter defining the position of the first result (inclusive)paramUpperExclExpr
- Expression for a parameter defining the position of the last result (exclusive)public <S> TypesafeSubquery<S> subquery(Class<S> candidateClass, String candidateAlias)
TypesafeQuery
subquery
in interface TypesafeQuery<T>
candidateClass
- Candidate for the subquerycandidateAlias
- Alias for the candidatepublic TypesafeSubquery<T> subquery(String candidateAlias)
TypesafeQuery
subquery
in interface TypesafeQuery<T>
candidateAlias
- Alias for the candidatepublic TypesafeQuery<T> setParameter(Expression paramExpr, Object value)
TypesafeQuery
setParameter
in interface TypesafeQuery<T>
paramExpr
- Parameter expressionvalue
- The valuepublic TypesafeQuery<T> setParameter(String paramName, Object value)
TypesafeQuery
setParameter
in interface TypesafeQuery<T>
paramName
- Parameter namevalue
- The valuepublic TypesafeQuery<T> setCandidates(Collection<T> candidates)
TypesafeQuery
setCandidates
in interface TypesafeQuery<T>
candidates
- The candidatespublic <T> List<T> executeList()
TypesafeQuery
executeList
in interface TypesafeQuery<T>
public <T> T executeUnique()
TypesafeQuery
executeUnique
in interface TypesafeQuery<T>
public List<Object[]> executeResultList(boolean distinct, Expression... exprs)
TypesafeQuery
executeResultList
in interface TypesafeQuery<T>
distinct
- Whether to provide distinct resultsexprs
- Result expression(s)public List<Object> executeResultList(boolean distinct, Expression expr)
TypesafeQuery
executeResultList
in interface TypesafeQuery<T>
distinct
- Whether to provide distinct resultsexpr
- Result expressionpublic <R> List<R> executeResultList(Class<R> resultCls, boolean distinct, Expression... exprs)
TypesafeQuery
executeResultList
in interface TypesafeQuery<T>
resultCls
- Result classdistinct
- Whether to provide distinct resultsexprs
- Result expression(s)public Object[] executeResultUnique(boolean distinct, Expression... exprs)
TypesafeQuery
executeResultUnique
in interface TypesafeQuery<T>
distinct
- Whether to provide distinct resultsexprs
- Result expression(s)public Object executeResultUnique(boolean distinct, Expression expr)
TypesafeQuery
executeResultUnique
in interface TypesafeQuery<T>
distinct
- Whether to provide distinct resultsexpr
- Result expressionpublic <R> R executeResultUnique(Class<R> resultCls, boolean distinct, Expression... exprs)
TypesafeQuery
executeResultUnique
in interface TypesafeQuery<T>
resultCls
- Result classdistinct
- Whether to provide distinct resultsexprs
- Result expression(s)protected org.datanucleus.store.query.Query getInternalQuery()
protected Object executeInternalQuery(org.datanucleus.store.query.Query internalQuery)
public long deletePersistentAll()
TypesafeQuery
deletePersistentAll
in interface TypesafeQuery<T>
public TypesafeQuery<T> set(Expression expr, Object val)
expr
- Expression for field of the candidateval
- The new valuepublic long update()
public long delete()
public javax.jdo.FetchPlan getFetchPlan()
TypesafeQuery
getFetchPlan
in interface TypesafeQuery<T>
public javax.jdo.PersistenceManager getPersistenceManager()
TypesafeQuery
getPersistenceManager
in interface TypesafeQuery<T>
public TypesafeQuery setIgnoreCache(boolean ignore)
TypesafeQuery
setIgnoreCache
in interface TypesafeQuery<T>
ignore
- Ignore the cache flagpublic TypesafeQuery addExtension(String key, Object value)
TypesafeQuery
addExtension
in interface TypesafeQuery<T>
key
- the key of the extensionvalue
- the value of the extensionpublic TypesafeQuery setExtensions(Map<String,Object> extensions)
TypesafeQuery
setExtensions
in interface TypesafeQuery<T>
extensions
- the map of extensionsTypesafeQuery.addExtension(java.lang.String, java.lang.Object)
public void close(Object result)
TypesafeQuery
close
in interface TypesafeQuery<T>
result
- The resultpublic void closeAll()
TypesafeQuery
closeAll
in interface TypesafeQuery<T>
public org.datanucleus.query.compiler.QueryCompilation compile(org.datanucleus.metadata.MetaDataManager mmgr, org.datanucleus.ClassLoaderResolver clr)
compile
in class AbstractTypesafeQuery<T>
mmgr
- Metadata managerclr
- ClassLoader resolverpublic String toString()
toString
in interface TypesafeQuery<T>
toString
in class Object
protected void discardCompiled()
discardCompiled
in class AbstractTypesafeQuery<T>
public static String getQueryClassNameForClassName(String name)
name
- Simple name of the class (without package)Copyright © 2023. All rights reserved.