org.jpox.store.rdbms.query
Class SQLQuery

java.lang.Object
  extended byorg.jpox.store.query.Query
      extended byorg.jpox.store.rdbms.query.BaseSQLQuery
          extended byorg.jpox.store.rdbms.query.SQLQuery
All Implemented Interfaces:
javax.jdo.Query, java.io.Serializable

public final class SQLQuery
extends BaseSQLQuery

A Query using SQL, and keeping to the JDO2 definition of a SQL query. The majority of this has to be specified in the query filter itself. Parameters are embodied in the query and are unnamed/untyped. There are no variables/imports. Ordering/grouping is explicit in the query.

Version:
$Revision: 1.4 $
See Also:
Query, Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.jpox.store.query.Query
Query.ResultObjectFactory
 
Field Summary
 
Fields inherited from class org.jpox.store.rdbms.query.BaseSQLQuery
fieldColumnNames, fieldNumbers, jdbcSqlText, LOCALISER_RDBMS, sqlText, statementExpressionIndex
 
Fields inherited from class org.jpox.store.query.Query
candidateClass, candidateClassName, dba, extensions, fetchPlan, filter, fromInclNo, grouping, ignoreCache, imports, isCompiled, isPreCompile, LOCALISER, ordering, parameterNames, parameters, parameterTypesByName, parsedImports, pm, queryResults, range, result, resultClass, resultClassName, subclasses, toExclNo, unique, unmodifiable, variableNames, variables, variableTypesByName
 
Fields inherited from interface javax.jdo.Query
JDOQL, SQL
 
Constructor Summary
SQLQuery(PersistenceManager pm, SQLQuery query)
          Constructor for a new query using the existing query.
SQLQuery(PersistenceManager pm, java.lang.String sql_text)
          Constructs a new query instance having the same criteria as the given query.
 
Method Summary
 void declareImports(java.lang.String imports)
          Set the import statements to be used to identify the fully qualified name of variables or parameters.
 void declareParameters(java.lang.String parameters)
          Declare the parameters to be used in the query.
 boolean equals(java.lang.Object obj)
          Equality operator
 java.lang.Object executeWithArray(java.lang.Object[] parameters)
          Execute the query and return the filtered List.
 java.lang.Object executeWithMap(java.util.Map parameterMap)
          Execute the query and return the filtered List.
protected  void generateQueryStatement()
          Method to perform any necessary pre-processing on the users query statement before we execute it.
 java.util.Collection performExecute(java.util.Map parameters)
          Execute the query and return the filtered QueryResult.
 
Methods inherited from class org.jpox.store.rdbms.query.BaseSQLQuery
compile, declareVariables, discardCompiled, getQueryResultForNoCandidateClass, performDeletePersistentAll, setCandidates, setCandidates, setFilter, setGrouping, setOrdering, setRange, setResult, setSubclasses, shouldReturnSingleRow
 
Methods inherited from class org.jpox.store.query.Query
addExtension, assertIsModifiable, close, closeAll, deletePersistentAll, deletePersistentAll, deletePersistentAll, execute, execute, execute, execute, executeQuery, getCandidateClass, getCandidateLoader, getExtension, getFetchPlan, getIgnoreCache, getPersistenceManager, getResultSetConcurrency, getResultSetType, getStatement, getStatement, getStoreManager, hashCode, isSubclasses, isUnmodifiable, prepareStatementForExecution, resolveClassDeclaration, setCandidateClassName, setClass, setExtensions, setIgnoreCache, setRange, setRange, setResultClass, setResultClassName, setUnique, setUnmodifiable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLQuery

public SQLQuery(PersistenceManager pm,
                SQLQuery query)
Constructor for a new query using the existing query.

Parameters:
pm - Persistence Manager
query - The existing query

SQLQuery

public SQLQuery(PersistenceManager pm,
                java.lang.String sql_text)
Constructs a new query instance having the same criteria as the given query.

Parameters:
pm - The PersistenceManager
sql_text - The SQL query string
Method Detail

equals

public boolean equals(java.lang.Object obj)
Equality operator

Overrides:
equals in class Query
Parameters:
obj - The object to compare against
Returns:
Whether they are equal

declareParameters

public void declareParameters(java.lang.String parameters)
Declare the parameters to be used in the query.

This implementation always throws a JDOUserException since this concept doesn't apply to SQL queries.

Specified by:
declareParameters in interface javax.jdo.Query
Overrides:
declareParameters in class Query
Parameters:
parameters - the parameters separated by semicolons.
Throws:
javax.jdo.JDOUserException - Always thrown.
See Also:
Query.declareVariables(java.lang.String)

declareImports

public void declareImports(java.lang.String imports)
Set the import statements to be used to identify the fully qualified name of variables or parameters.

This implementation always throws a JDOUserException since this concept doesn't apply to SQL queries.

Specified by:
declareImports in interface javax.jdo.Query
Overrides:
declareImports in class Query
Parameters:
imports - import statements separated by semicolons.
Throws:
javax.jdo.JDOUserException - Always thrown.
See Also:
Query.declareImports(java.lang.String)

generateQueryStatement

protected void generateQueryStatement()
Method to perform any necessary pre-processing on the users query statement before we execute it. SQL queries are not modified in any way, as per JDO2 spec section 14.7.

Specified by:
generateQueryStatement in class BaseSQLQuery

executeWithArray

public java.lang.Object executeWithArray(java.lang.Object[] parameters)
Execute the query and return the filtered List. Overrides the version in Query so that we can allow for not having parameter names in SQL.

Specified by:
executeWithArray in interface javax.jdo.Query
Overrides:
executeWithArray in class Query
Parameters:
parameters - the Object array with all of the parameters.
Returns:
the filtered List.
See Also:
Query.executeWithArray(Object[])

executeWithMap

public java.lang.Object executeWithMap(java.util.Map parameterMap)
Execute the query and return the filtered List. Overrides the version in Query so that we can allow for not having parameter names in SQL and impose the restriction that all map keys are integers starting at 1.

Specified by:
executeWithMap in interface javax.jdo.Query
Overrides:
executeWithMap in class Query
Parameters:
parameterMap - the Map with all of the parameters.
Returns:
the filtered List.
See Also:
Query.executeWithArray(Object[])

performExecute

public java.util.Collection performExecute(java.util.Map parameters)
Execute the query and return the filtered QueryResult.

Specified by:
performExecute in class BaseSQLQuery
Parameters:
parameters - the Map containing all of the parameters.
Returns:
the filtered QueryResult.


Copyright © -2007 . All Rights Reserved.