Package com.j_spaces.core.client
Class SQLQuery<T>
java.lang.Object
com.j_spaces.core.client.SQLQuery<T>
- All Implemented Interfaces:
ISpaceQuery<T>,Serializable
The SQLQuery class is used to query the space using the SQL syntax. The query statement should
only include the WHERE clause.
Date and Time Formats
The following Date/TimeStamp Format is supported:
The following Time Format is supported:
Date and Time Formats
The following Date/TimeStamp Format is supported:
'yyyy-mm-dd hh:mm:ss' - i.e. '2004-12-20 20:40:10'The following Time Format is supported:
'hh:mm:ss' - i.e. '20:40:10'-
Constructor Summary
ConstructorsConstructorDescriptionSQLQuery()Empty constructor.Creates a SQLQuery using the specified type and expression.SQLQuery(Class<T> type, String sqlExpression, QueryResultType queryResultType) Creates a SQLQuery using the specified type, expression and result type.SQLQuery(Class<T> type, String sqlExpression, QueryResultType queryResultType, Object... parameters) Creates a SQLQuery using the specified type, expression, result type and parameters.Creates a SQLQuery using the specified type, expression and parameters.Creates a SQLQuery using the specified type and expression.SQLQuery(String typeName, String sqlExpression, QueryResultType queryResultType) Creates a SQLQuery using the specified type, expression and result type.SQLQuery(String typeName, String sqlExpression, QueryResultType queryResultType, Object... parameters) Creates a SQLQuery using the specified type, expression, result type and parameters.Creates a SQLQuery using the specified type, expression and parameters.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether someSQLQueryis "equal to" this one.Returns a string representation of this SQLQuery, in the form of:Deprecated.Use SQLQuery with parameters instead of a template.Object[]String[]Returns the projections set on this query, null means no projection is used and all the properties should be returned.getQuery()Returns the 'WHERE' part of this SQL Query.Returns the result type of this query.Gets the routing value of this query.Returns a string representation of this SQLQuery, in the form of:Returns a string representation of this SQLQuery, in the form of:Returns the name of the type which will be queried.inthashCode()booleanbooleanReturns true if the query has a where clause.booleanThis method should be used for check expression string.booleanbooleanReturns true if this query is a stored proceduresetParameter(int index, Object value) Set the query parameter value.voidsetParameters(Object... parameters) setProjections(String... properties) Sets projection properties which specifies that a result for an operation using this query should contain data for the specified projection properties.voidsetResultAsPacket(boolean resultAsPacket) voidsetRouting(Object routing) Sets the routing value of this query.toString()Returns a string representation of this SQLQuery, in the form of:withExplainPlanV3(String tableName, String name, String[] projectedColumns, boolean distinct)
-
Constructor Details
-
SQLQuery
public SQLQuery()Empty constructor. -
SQLQuery
Creates a SQLQuery using the specified type and expression.- Parameters:
typeName- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).
-
SQLQuery
Creates a SQLQuery using the specified type, expression and result type.- Parameters:
typeName- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).queryResultType- Type of result.- Since:
- 8.0
-
SQLQuery
Creates a SQLQuery using the specified type, expression and parameters.- Parameters:
typeName- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).parameters- Parameters for the sql query.
-
SQLQuery
public SQLQuery(String typeName, String sqlExpression, QueryResultType queryResultType, Object... parameters) Creates a SQLQuery using the specified type, expression, result type and parameters.- Parameters:
typeName- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).queryResultType- Type of result.parameters- Parameters for the sql query.- Since:
- 8.0
-
SQLQuery
Creates a SQLQuery using the specified type and expression.- Parameters:
type- Entry class to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).
-
SQLQuery
Creates a SQLQuery using the specified type, expression and result type.- Parameters:
type- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).queryResultType- Type of result.- Since:
- 8.0
-
SQLQuery
Creates a SQLQuery using the specified type, expression and parameters.- Parameters:
type- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).parameters- Parameters for the sql query.
-
SQLQuery
public SQLQuery(Class<T> type, String sqlExpression, QueryResultType queryResultType, Object... parameters) Creates a SQLQuery using the specified type, expression, result type and parameters.- Parameters:
type- Entry type to be queried.sqlExpression- The SQL Query expression (contents of the WHERE part).queryResultType- Type of result.parameters- Parameters for the sql query.- Since:
- 8.0
-
SQLQuery
Deprecated.UseSQLQuery(Class, String)orSQLQuery(String, String)instead.This constructor has been depracated and should not be used.
-
-
Method Details
-
withExplainPlan
-
getExplainPlan
-
withExplainPlanV3
-
getObject
Deprecated.Use SQLQuery with parameters instead of a template.This method has been depracated and should not be used. -
getTypeName
Returns the name of the type which will be queried.- Returns:
- the type name
-
isNullExpression
public boolean isNullExpression()This method should be used for check expression string.- Returns:
trueif expression is null or empty
-
getQuery
Returns the 'WHERE' part of this SQL Query.- Returns:
- 'WHERE' part expression.
-
getFromQuery
Returns a string representation of this SQLQuery, in the form of:FROM table name WHERE query expression
- Returns:
- the string representation of the query
-
getSelectAllQuery
Returns a string representation of this SQLQuery, in the form of:SELECT * FROM table name WHERE query expression
- Returns:
- a string representation of the object.
-
getSelectCountQuery
Returns a string representation of this SQLQuery, in the form of:SELECT count(*) FROM table name WHERE query expression
- Returns:
- a string representation of the object.
-
toString
Returns a string representation of this SQLQuery, in the form of:SELECT * FROM table name WHERE query expression
-
isStoredProcedure
public boolean isStoredProcedure()Returns true if this query is a stored procedure- Returns:
trueif represents a stored procedure
-
hasWhereClause
public boolean hasWhereClause()Returns true if the query has a where clause. Used in partial SQLQuery- Returns:
truehas a "where" part
-
getParameters
- Returns:
- the parameters
-
hasParameters
public boolean hasParameters()- Returns:
- true if the SQLQuery has parameters
-
setParameters
- Parameters:
parameters- the parameters to set
-
setParameter
Set the query parameter value.- Parameters:
index- parameter index - start with 1value- parameter value
-
getQueryResultType
Returns the result type of this query. -
setRouting
Sets the routing value of this query.- Parameters:
routing- The routing value
-
getRouting
Gets the routing value of this query.- Returns:
- The routing value of the query
-
hashCode
public int hashCode() -
equals
Indicates whether someSQLQueryis "equal to" this one. -
setProjections
Sets projection properties which specifies that a result for an operation using this query should contain data for the specified projection properties. Other properties which were not specifies as a projection will not contain data. By default, if no projection was added, all the properties are returned with full data. -
getProjections
Returns the projections set on this query, null means no projection is used and all the properties should be returned. -
isResultAsPacket
public boolean isResultAsPacket() -
setResultAsPacket
public void setResultAsPacket(boolean resultAsPacket)
-
SQLQuery(Class, String)orSQLQuery(String, String)instead.