Package org.postgresql.core.v3
Class BatchedQuery
- java.lang.Object
-
- org.postgresql.core.v3.BatchedQuery
-
- All Implemented Interfaces:
Query
public class BatchedQuery extends java.lang.ObjectPurpose of this object is to support batched query re write behaviour. Responsibility for tracking the batch size and implement the clean up of the query fragments after the batch execute is complete. Intended to be used to wrap a Query that is present in the batchStatements collection.- Author:
- Jeremy Whiting jwhiting@redhat.com, Christopher Deckers (chrriis@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description BatchedQuery(NativeQuery query, TypeTransferModeRegistry transferModeRegistry, int valuesBraceOpenPosition, int valuesBraceClosePosition, boolean sanitiserDisabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this query and free any server-side resources associated with it.ParameterListcreateParameterList()Create a ParameterList suitable for storing parameters associated with this Query.BatchedQueryderiveForMultiBatch(int valueBlock)intgetBatchSize()Get the number of times this Query has been batched.intgetBindCount()intgetMaxResultRowSize()Return maximum size in bytes that each result row from this query may return.java.lang.StringgetNativeSql()Method to return the sql based on number of batches.java.util.Map<java.lang.String,java.lang.Integer>getResultSetColumnNameIndexMap()Get a map that a result set can use to find the index associated to a name.SqlCommandgetSqlCommand()Returns properties of the query (sql keyword, and some other parsing info).org.postgresql.core.v3.SimpleQuery[]getSubqueries()Return a list of the Query objects that make up this query.booleanhasBinaryFields()booleanisEmpty()booleanisStatementDescribed()voidresetNeedUpdateFieldFormats()voidsetHasBinaryFields(boolean hasBinaryFields)java.lang.StringtoString()java.lang.StringtoString(ParameterList parameters)Returns string representation of the query, substituting particular parameter values for parameter placeholders.java.lang.StringtoString(ParameterList params, SqlSerializationContext context)Returns string representation of the query, substituting particular parameter values for parameter placeholders.
-
-
-
Constructor Detail
-
BatchedQuery
public BatchedQuery(NativeQuery query, TypeTransferModeRegistry transferModeRegistry, int valuesBraceOpenPosition, int valuesBraceClosePosition, boolean sanitiserDisabled)
-
-
Method Detail
-
deriveForMultiBatch
public BatchedQuery deriveForMultiBatch(int valueBlock)
-
getBatchSize
public int getBatchSize()
Description copied from interface:QueryGet the number of times this Query has been batched.- Specified by:
getBatchSizein interfaceQuery- Returns:
- number of times
addBatch()has been called.
-
getNativeSql
public java.lang.String getNativeSql()
Method to return the sql based on number of batches. Skipping the initial batch.- Specified by:
getNativeSqlin interfaceQuery- Returns:
- SQL in native for database format
-
toString
public java.lang.String toString(ParameterList params, SqlSerializationContext context)
Description copied from interface:QueryReturns string representation of the query, substituting particular parameter values for parameter placeholders.- Specified by:
toStringin interfaceQuery- Parameters:
params- a ParameterList returned by this Query'sQuery.createParameterList()method, ornullto leave the parameter placeholders unsubstituted.context- specifies configuration for converting the parameters to string- Returns:
- string representation of this query
-
createParameterList
public ParameterList createParameterList()
Description copied from interface:QueryCreate a ParameterList suitable for storing parameters associated with this Query.If this query has no parameters, a ParameterList will be returned, but it may be a shared immutable object. If this query does have parameters, the returned ParameterList is a new list, unshared by other callers.
- Specified by:
createParameterListin interfaceQuery- Returns:
- a suitable ParameterList instance for this query
-
toString
public java.lang.String toString(ParameterList parameters)
Description copied from interface:QueryReturns string representation of the query, substituting particular parameter values for parameter placeholders.Note: the method replaces the values on a best-effort basis as it might omit the replacements for parameters that can't be processed several times. For instance,
InputStreamcan be processed only once.- Specified by:
toStringin interfaceQuery- Parameters:
parameters- a ParameterList returned by this Query'sQuery.createParameterList()method, ornullto leave the parameter placeholders unsubstituted.- Returns:
- string representation of this query
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
close
public void close()
Description copied from interface:QueryClose this query and free any server-side resources associated with it. The resources may not be immediately deallocated, but closing a Query may make the deallocation more prompt.A closed Query should not be executed.
-
getSubqueries
public org.postgresql.core.v3.SimpleQuery[] getSubqueries()
Description copied from interface:QueryReturn a list of the Query objects that make up this query. If this object is already a SimpleQuery, returns null (avoids an extra array construction in the common case).- Specified by:
getSubqueriesin interfaceQuery- Returns:
- an array of single-statement queries, or
nullif this object is already a single-statement query.
-
getMaxResultRowSize
public int getMaxResultRowSize()
Return maximum size in bytes that each result row from this query may return. Mainly used for batches that return results.Results are cached until/unless the query is re-described.
- Returns:
- Max size of result data in bytes according to returned fields, 0 if no results, -1 if result is unbounded.
- Throws:
java.lang.IllegalStateException- if the query is not described
-
resetNeedUpdateFieldFormats
public void resetNeedUpdateFieldFormats()
-
hasBinaryFields
public boolean hasBinaryFields()
-
setHasBinaryFields
public void setHasBinaryFields(boolean hasBinaryFields)
-
isStatementDescribed
public boolean isStatementDescribed()
- Specified by:
isStatementDescribedin interfaceQuery
-
getBindCount
public final int getBindCount()
-
getResultSetColumnNameIndexMap
public java.util.Map<java.lang.String,java.lang.Integer> getResultSetColumnNameIndexMap()
Description copied from interface:QueryGet a map that a result set can use to find the index associated to a name.- Specified by:
getResultSetColumnNameIndexMapin interfaceQuery- Returns:
- null if the query implementation does not support this method.
-
getSqlCommand
public SqlCommand getSqlCommand()
Description copied from interface:QueryReturns properties of the query (sql keyword, and some other parsing info).- Specified by:
getSqlCommandin interfaceQuery- Returns:
- returns properties of the query (sql keyword, and some other parsing info) or null if not applicable
-
-