Package com.j_spaces.jdbc
Class AbstractDMLQuery
java.lang.Object
com.j_spaces.jdbc.AbstractDMLQuery
- Direct Known Subclasses:
DeleteQuery,InsertQuery,ProcedureQuery,SelectQuery,UpdateQuery
- Author:
- Michael Mitrani, 2Train4, 2004 This abstract class is the super class for DML queries like: SELECT, DELETE, UPDATE and INSERT
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected IQueryExecutorprotected OperationIDprotected AbstractProjectionTemplateprotected QueryResultTypeInternalprotected List<QueryTableData>protected ExpNodeprotected booleanprotected Object[]protected Listprotected RowNumNodeprotected SecurityInterceptorprotected ConcurrentHashMap<String,QueryTableData> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a column to the list of columns.addTableWithAlias(String table, String alias) voidassignParameters(SQLQuery<?> sqlQuery, IDirectSpaceProxy proxy) voidbuild()Build query internal structures - called after parsingvoidConvert the expression tree to space queries in form of IEntryPacket templatesabstract AbstractDMLQueryclone()booleanGets whether this query contains sub queries.executePreparedValuesBatch(ISpaceProxy space, Transaction transaction, GPreparedStatement.PreparedValuesCollection preparedValuesCollection) Executes a query with batched prepared values.protected voidexecuteSubQueries(ISpaceProxy space, Transaction txn) protected voidfilterByRownum(Collection<IEntryPacket> entries) booleanintObject[]getQueryColumnByAlias(String alias) Returns the list of columns in this query as Strings.intGets the routing value of the query.protected intgetTableByAlias(String alias) Return a table name according to its alias.getTableData(String tableName) longbooleanbooleanbooleanbooleanGets whether the query is in dirty statebooleanGets whether this query is forced to be executed under transaction.booleanisJoined()booleanbooleanbooleanGets whether this query is a SELECT query.voidprepare(ISpaceProxy space, Transaction txn) Set the prepared values on the expression treeprotected voidvoidsetBuildOnly(boolean isBuildOnly) voidsetContainsQuery(boolean containsQuery) voidsetContainsSubQueries(boolean containsSubQueries) voidsetConvertResultToArray(boolean convertResultToArray) voidsetExplainPlan(ExplainPlan _explainPlan) voidsetExpTree(ExpNode rootNode) Sets the root node of the expression tree.voidsetIfExists(boolean ifExists) voidsetMaxResults(int maxResults) voidsetMinEntriesToWaitFor(int minEntriesToWaitFor) voidsetOperationID(OperationID operationID) voidsetPrepared(boolean isPrepared) voidsetPreparedValues(Object[] preparedValues) voidsetProjectionTemplate(AbstractProjectionTemplate projectionTemplate) voidsetQueryResultType(QueryResultTypeInternal queryResultType) voidsetReadModifier(int readModifier) voidsetReturnResult(boolean returnResult) voidsetRouting(Object routing) Sets the routing value of the query.voidsetRownum(RowNumNode rownum) voidsetSecurityInterceptor(SecurityInterceptor securityInterceptor) voidsetSession(QuerySession session) voidsetTableName(String table) sets the table name of the query.voidsetTemplatePreparedValues(ITypeDesc typeDesc, Object[] fieldValues) voidsetTimeout(long timeout) protected voidvoidvalidateQuery(ISpaceProxy space) Each query should have its own specific validations.voidvalidateQuery(SpaceTypeManager typeManager) protected voidMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.j_spaces.jdbc.Query
executeOnSpace
-
Field Details
-
isPrepared
protected boolean isPrepared -
queryColumns
-
expTree
-
preparedValues
-
_tablesData
-
rownum
-
valueMap
-
tables
-
_containsQuery
protected transient boolean _containsQuery -
_buildOnly
protected boolean _buildOnly -
_convertResultToArray
protected boolean _convertResultToArray -
_executor
-
_operationID
-
_queryResultType
-
securityInterceptor
-
_projectionTemplate
-
-
Constructor Details
-
AbstractDMLQuery
public AbstractDMLQuery()
-
-
Method Details
-
build
Build query internal structures - called after parsing- Specified by:
buildin interfaceQuery- Throws:
SQLException
-
validateBuiltTemplates
- Throws:
SQLException
-
isContainsQuery
public boolean isContainsQuery() -
setContainsQuery
public void setContainsQuery(boolean containsQuery) -
getReadModifier
public int getReadModifier()- Returns:
- the readModifier
-
setReadModifier
public void setReadModifier(int readModifier) - Parameters:
readModifier- the readModifier to set
-
setPrepared
public void setPrepared(boolean isPrepared) - Parameters:
isPrepared- is this a PreparedStatment or not.
-
isPrepared
public boolean isPrepared()- Specified by:
isPreparedin interfaceQuery- Returns:
- isPrepared is this a PreparedStatment or not.
-
getQueryColumns
Returns the list of columns in this query as Strings. if the list is empty it means all columns (the '*' notation). -
getQueryColumnByAlias
-
addColumn
Add a column to the list of columns.- Parameters:
column- the column to add
-
setTableName
sets the table name of the query. -
getTableName
- Returns:
- String the table name of the query
-
setExpTree
Sets the root node of the expression tree. -
getExpTree
- Returns:
- the root node of the expression tree.
-
isJoined
public boolean isJoined() -
clone
-
setRownum
-
getRownum
-
getPreparedValues
-
setPreparedValues
-
getSession
-
setSession
- Specified by:
setSessionin interfaceQuery
-
setTemplatePreparedValues
-
addTableWithAlias
-
getTableByAlias
Return a table name according to its alias.- Returns:
- The table name
-
isBuildOnly
public boolean isBuildOnly() -
setBuildOnly
public void setBuildOnly(boolean isBuildOnly) -
isConvertResultToArray
public boolean isConvertResultToArray()- Returns:
- true if convert result to array
-
setConvertResultToArray
public void setConvertResultToArray(boolean convertResultToArray) - Parameters:
convertResultToArray-
-
buildTemplates
Convert the expression tree to space queries in form of IEntryPacket templates- Throws:
SQLException
-
getTemplatePacketIfExists
-
getTypeInfo
- Returns:
- ITypeDesc
-
prepare
Set the prepared values on the expression tree- Throws:
SQLException
-
executeSubQueries
- Throws:
SQLException
-
isReturnResult
public boolean isReturnResult() -
setReturnResult
public void setReturnResult(boolean returnResult) -
getRownumLimit
protected int getRownumLimit()- Returns:
- row number limit
-
filterByRownum
-
getOperationID
- Returns:
- the operationID
-
setOperationID
- Parameters:
operationID- the operationID to set
-
getQueryResultType
-
setQueryResultType
-
setSecurityInterceptor
- Specified by:
setSecurityInterceptorin interfaceQuery
-
getSecurityInterceptor
- Returns:
- the securityInterceptor
-
getTablesData
-
getTablesNames
-
getTableData
-
getTableData
-
validateQuery
Description copied from interface:QueryEach query should have its own specific validations. this is the place to do them. if some validation fail, an SQLException will be thrown.- Specified by:
validateQueryin interfaceQuery- Throws:
SQLException
-
validateQuery
- Specified by:
validateQueryin interfaceQuery- Throws:
SQLException
-
getBuilder
-
getTimeout
public long getTimeout() -
setTimeout
public void setTimeout(long timeout) -
getIfExists
public boolean getIfExists() -
setIfExists
public void setIfExists(boolean ifExists) -
setRouting
Sets the routing value of the query. -
getRouting
Gets the routing value of the query. -
setProjectionTemplate
-
getProjectionTemplate
-
isDirtyState
public boolean isDirtyState()Gets whether the query is in dirty state -
isSelectQuery
public boolean isSelectQuery()Gets whether this query is a SELECT query. -
isForceUnderTransaction
public boolean isForceUnderTransaction()Gets whether this query is forced to be executed under transaction.- Specified by:
isForceUnderTransactionin interfaceQuery
-
containsSubQueries
public boolean containsSubQueries()Description copied from interface:QueryGets whether this query contains sub queries.- Specified by:
containsSubQueriesin interfaceQuery
-
setContainsSubQueries
public void setContainsSubQueries(boolean containsSubQueries) -
executePreparedValuesBatch
public BatchResponsePacket executePreparedValuesBatch(ISpaceProxy space, Transaction transaction, GPreparedStatement.PreparedValuesCollection preparedValuesCollection) throws SQLException Executes a query with batched prepared values. This is the default implementation - NOT optimized.- Returns:
- BatchResponsePacket
- Throws:
SQLException
-
setMaxResults
public void setMaxResults(int maxResults) -
setMinEntriesToWaitFor
public void setMinEntriesToWaitFor(int minEntriesToWaitFor) -
getMinEntriesToWaitFor
public int getMinEntriesToWaitFor() -
assignParameters
-
getExplainPlan
-
setExplainPlan
-
writeExternal
- Throws:
IOException
-
readExternal
- Throws:
IOExceptionClassNotFoundException
-