Package org.postgresql.core.v3
Class BatchedQuery
java.lang.Object
org.postgresql.core.v3.BatchedQuery
- All Implemented Interfaces:
Query
Purpose 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.
-
Constructor Summary
ConstructorsConstructorDescriptionBatchedQuery
(NativeQuery query, TypeTransferModeRegistry transferModeRegistry, int valuesBraceOpenPosition, int valuesBraceClosePosition, boolean sanitiserDisabled) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this query and free any server-side resources associated with it.Create a ParameterList suitable for storing parameters associated with this Query.deriveForMultiBatch
(int valueBlock) int
Get the number of times this Query has been batched.final int
int
Return maximum size in bytes that each result row from this query may return.Method to return the sql based on number of batches.Get a map that a result set can use to find the index associated to a name.Returns properties of the query (sql keyword, and some other parsing info).org.postgresql.core.v3.SimpleQuery @Nullable []
Return a list of the Query objects that make up this query.boolean
boolean
isEmpty()
boolean
void
void
setHasBinaryFields
(boolean hasBinaryFields) toString()
toString
(@Nullable ParameterList params) Stringize this query to a human-readable form, substituting particular parameter values for parameter placeholders.
-
Constructor Details
-
BatchedQuery
public BatchedQuery(NativeQuery query, TypeTransferModeRegistry transferModeRegistry, int valuesBraceOpenPosition, int valuesBraceClosePosition, boolean sanitiserDisabled)
-
-
Method Details
-
deriveForMultiBatch
-
getBatchSize
public int getBatchSize()Description copied from interface:Query
Get the number of times this Query has been batched.- Specified by:
getBatchSize
in interfaceQuery
- Returns:
- number of times
addBatch()
has been called.
-
getNativeSql
Method to return the sql based on number of batches. Skipping the initial batch.- Specified by:
getNativeSql
in interfaceQuery
- Returns:
- SQL in native for database format
-
toString
Description copied from interface:Query
Stringize this query to a human-readable form, substituting particular parameter values for parameter placeholders.- Specified by:
toString
in interfaceQuery
- Parameters:
params
- a ParameterList returned by this Query'sQuery.createParameterList()
method, ornull
to leave the parameter placeholders unsubstituted.- Returns:
- a human-readable representation of this query
-
createParameterList
Description copied from interface:Query
Create 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:
createParameterList
in interfaceQuery
- Returns:
- a suitable ParameterList instance for this query
-
toString
-
close
public void close()Description copied from interface:Query
Close 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 @Nullable [] getSubqueries()Description copied from interface:Query
Return 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:
getSubqueries
in interfaceQuery
- Returns:
- an array of single-statement queries, or
null
if 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:
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:
isStatementDescribed
in interfaceQuery
-
isEmpty
public boolean isEmpty() -
getBindCount
public final int getBindCount() -
getResultSetColumnNameIndexMap
Description copied from interface:Query
Get a map that a result set can use to find the index associated to a name.- Specified by:
getResultSetColumnNameIndexMap
in interfaceQuery
- Returns:
- null if the query implementation does not support this method.
-
getSqlCommand
Description copied from interface:Query
Returns properties of the query (sql keyword, and some other parsing info).- Specified by:
getSqlCommand
in interfaceQuery
- Returns:
- returns properties of the query (sql keyword, and some other parsing info) or null if not applicable
-