GigaSpaces XAP 8.0 API

com.j_spaces.core.client
Class SQLQuery<T>

java.lang.Object
  extended by com.j_spaces.core.client.SQLQuery<T>
All Implemented Interfaces:
ISpaceQuery<T>, Query<T>, Serializable
Direct Known Subclasses:
ContinousQuery

public class SQLQuery<T>
extends Object
implements Query<T>, Serializable

The SQLQuery class is used to query the space using the SQL syntax. The query statement should only include the WHERE clause.

Supported JavaSpace operations
read/take/readMultiple/takeMultiple (with JavaSpace.NO_WAIT timeout)

UnSupported JavaSpace operations
Notify/readIfExists/takeIfExists and read/take/readMultiple/takeMultiple (with longer timeouts than JSpace.NO_WAIT)

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'

See Also:
thrown when space operations with SQLQuery fails., Serialized Form

Constructor Summary
SQLQuery()
          Empty constructor.
SQLQuery(Class<T> type, String sqlExpression)
          Creates a SQLQuery using the specified type and expression.
SQLQuery(Class<T> type, String sqlExpression, Object... parameters)
          Creates a SQLQuery using the specified type, expression and parameters.
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.
SQLQuery(String typeName, String sqlExpression)
          Creates a SQLQuery using the specified type and expression.
SQLQuery(String typeName, String sqlExpression, Object... parameters)
          Creates a SQLQuery using the specified type, expression and parameters.
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.
SQLQuery(T object, String sqlQuery)
          Deprecated. Use SQLQuery(Class, String) or SQLQuery(String, String) instead.
SQLQuery(T object, String sqlQuery, Object... parameters)
          Deprecated. Use SQLQuery(Class, String, Object...) or SQLQuery(String, String, Object...) instead.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some SQLQuery is "equal to" this one.
 String getClassName()
          Deprecated. Use getTypeName() instead.
 Entry getEntry()
          Deprecated. Use SQLQuery with parameters instead of a template.
 String getFromQuery()
          Returns a string representation of this SQLQuery, in the form of: FROM table name WHERE query expression
 T getObject()
          Deprecated. Use SQLQuery with parameters instead of a template.
 Object[] getParameters()
           
 String getQuery()
          Returns the 'WHERE' part of this SQL Query.
 QueryResultType getQueryResultType()
          Returns the result type of this query.
 Object getRouting()
          Gets the routing value of this query.
 String getSelectAllQuery()
          Returns a string representation of this SQLQuery, in the form of: SELECT * FROM table name WHERE query expression
 String getSelectCountQuery()
          Returns a string representation of this SQLQuery, in the form of: SELECT count(*) FROM table name WHERE query expression
 String getTypeName()
          Returns the name of the type which will be queried.
 int hashCode()
           
 boolean hasParameters()
           
 boolean hasWhereClause()
          Returns true if the query has a where clause.
 boolean isNullExpression()
          This method should be used for check expression string.
 boolean isStoredProcedure()
          Returns true if this query is a stored procedure
 void setClassName(String className)
          Deprecated. Use SQLQuery(String, String) instead.
 SQLQuery<T> setParameter(int index, Object value)
          Set the query parameter value.
 void setParameters(Object... parameters)
           
 void setQuery(String wherePart)
          Deprecated. Use SQLQuery(String, String) instead.
 void setRouting(Object routing)
          Sets the routing value of this query.
 void setTemplate(Entry entry)
          Deprecated. Use SQLQuery with parameters instead of a template.
 void setTemplate(T object)
          Deprecated. Use SQLQuery with parameters instead of a template.
 String toString()
          Returns a string representation of this SQLQuery, in the form of: SELECT * FROM table name WHERE query expression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLQuery

public SQLQuery()
Empty constructor.


SQLQuery

public SQLQuery(String typeName,
                String sqlExpression)
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

public SQLQuery(String typeName,
                String sqlExpression,
                QueryResultType queryResultType)
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

public SQLQuery(String typeName,
                String sqlExpression,
                Object... parameters)
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

public SQLQuery(Class<T> type,
                String sqlExpression)
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

public SQLQuery(Class<T> type,
                String sqlExpression,
                QueryResultType queryResultType)
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

public SQLQuery(Class<T> type,
                String sqlExpression,
                Object... parameters)
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
public SQLQuery(T object,
                           String sqlQuery)
Deprecated. Use SQLQuery(Class, String) or SQLQuery(String, String) instead.

This constructor has been depracated and should not be used.


SQLQuery

@Deprecated
public SQLQuery(T object,
                           String sqlQuery,
                           Object... parameters)
Deprecated. Use SQLQuery(Class, String, Object...) or SQLQuery(String, String, Object...) instead.

This constructor has been depracated and should not be used.

Method Detail

getObject

@Deprecated
public T getObject()
Deprecated. Use SQLQuery with parameters instead of a template.

This method has been depracated and should not be used.


getEntry

@Deprecated
public Entry getEntry()
Deprecated. Use SQLQuery with parameters instead of a template.

This method has been depracated and should not be used.


getTypeName

public String getTypeName()
Returns the name of the type which will be queried.

Returns:
the type name

getClassName

@Deprecated
public String getClassName()
Deprecated. Use getTypeName() instead.

Extract the Entry class name for the current query.

Returns:
Returns the Entry class Name.

setClassName

@Deprecated
public void setClassName(String className)
Deprecated. Use SQLQuery(String, String) instead.

This method has been depracated and should not be used.

Specified by:
setClassName in interface Query<T>
Parameters:
className - The Entry class name to be set.

setQuery

@Deprecated
public void setQuery(String wherePart)
Deprecated. Use SQLQuery(String, String) instead.

This method has been depracated and should not be used.

Specified by:
setQuery in interface Query<T>
Parameters:
wherePart - WHERE statement

setTemplate

@Deprecated
public void setTemplate(Entry entry)
Deprecated. Use SQLQuery with parameters instead of a template.

This method has been depracated and should not be used.


setTemplate

@Deprecated
public void setTemplate(T object)
Deprecated. Use SQLQuery with parameters instead of a template.

This method has been depracated and should not be used.


isNullExpression

public boolean isNullExpression()
This method should be used for check expression string.

Returns:
true if expression is null or empty

getQuery

public String getQuery()
Returns the 'WHERE' part of this SQL Query.

Returns:
'WHERE' part expression.

getFromQuery

public String 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

public String 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

public String 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

public String toString()
Returns a string representation of this SQLQuery, in the form of:

SELECT * FROM table name WHERE query expression

Overrides:
toString in class Object
Returns:
a string representation of the object.

isStoredProcedure

public boolean isStoredProcedure()
Returns true if this query is a stored procedure

Returns:
true if represents a stored procedure

hasWhereClause

public boolean hasWhereClause()
Returns true if the query has a where clause. Used in partial SQLQuery

Returns:
true has a "where" part

getParameters

public Object[] getParameters()
Returns:
the parameters

hasParameters

public boolean hasParameters()
Returns:
true if the SQLQuery has parameters

setParameters

public void setParameters(Object... parameters)
Parameters:
parameters - the parameters to set

setParameter

public SQLQuery<T> setParameter(int index,
                                Object value)
Set the query parameter value.

Parameters:
index - parameter index - start with 1
value - parameter value

getQueryResultType

public QueryResultType getQueryResultType()
Returns the result type of this query.


setRouting

public void setRouting(Object routing)
Sets the routing value of this query.

Parameters:
routing - The routing value

getRouting

public Object getRouting()
Gets the routing value of this query.

Returns:
The routing value of the query

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Indicates whether some SQLQuery is "equal to" this one.

Overrides:
equals in class Object
Returns:
true if the input object object is not null, of type SQLQuery and this query's SQL expression, class (class name) and parameters are equal to the input SQLQuery.

GigaSpaces XAP 8.0 API

Copyright © GigaSpaces.