Class SqlBatchHandler
- java.lang.Object
-
- org.jdbi.v3.sqlobject.statement.internal.CustomizingStatementHandler<PreparedBatch>
-
- org.jdbi.v3.sqlobject.statement.internal.SqlBatchHandler
-
- All Implemented Interfaces:
ExtensionHandler
public class SqlBatchHandler extends CustomizingStatementHandler<PreparedBatch>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceSqlBatchHandler.ChunkSizeFunctionprivate static classSqlBatchHandler.ConstantChunkSizeFunctionprivate static classSqlBatchHandler.ParamBasedChunkSizeFunction
-
Field Summary
Fields Modifier and Type Field Description private SqlBatchHandler.ChunkSizeFunctionbatchChunkSizeprivate java.util.function.Function<PreparedBatch,ResultIterator<?>>batchIntermediateprivate ResultReturnermagicprivate SqlBatchsqlBatch-
Fields inherited from interface org.jdbi.v3.core.extension.ExtensionHandler
EQUALS_HANDLER, HASHCODE_HANDLER, NULL_HANDLER
-
-
Constructor Summary
Constructors Constructor Description SqlBatchHandler(java.lang.Class<?> sqlObjectType, java.lang.reflect.Method method)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidconfigureReturner(PreparedBatch stmt, SqlObjectStatementConfiguration cfg)(package private) PreparedBatchcreateStatement(Handle handle, java.lang.String locatedSql)private SqlBatchHandler.ChunkSizeFunctiondetermineBatchChunkSize(java.lang.Class<?> sqlObjectType, java.lang.reflect.Method method)private ResultIterator<?>executeBatch(Handle handle, java.util.function.Supplier<PreparedBatch> preparedBatchSupplier)(package private) java.lang.reflect.TypegetParameterType(java.lang.reflect.Parameter parameter)private intindexOfBatchChunkSizeParameter(java.lang.reflect.Method method)private static java.lang.StringinvalidReturnTypeMessage(java.lang.reflect.Method method)java.lang.Objectinvoke(HandleSupplier handleSupplier, java.lang.Object target, java.lang.Object... args)Gets invoked to return a value for the method that this handler was bound to.private java.util.function.Function<PreparedBatch,ResultIterator<?>>mapToBoolean(java.util.function.Function<PreparedBatch,ResultIterator<?>> modCounts)private static booleanreturnTypeIsValid(java.lang.Class<?> type)voidwarm(ConfigRegistry config)Called after the method handler is constructed to pre-initialize any important configuration data structures.private java.util.Iterator<java.lang.Object[]>zipArgs(java.lang.reflect.Method method, java.lang.Object[] args)-
Methods inherited from class org.jdbi.v3.sqlobject.statement.internal.CustomizingStatementHandler
applyCustomizers, getMethod, locateSql, rowMapperFor, rowReducerFor
-
-
-
-
Field Detail
-
sqlBatch
private final SqlBatch sqlBatch
-
batchChunkSize
private final SqlBatchHandler.ChunkSizeFunction batchChunkSize
-
batchIntermediate
private final java.util.function.Function<PreparedBatch,ResultIterator<?>> batchIntermediate
-
magic
private final ResultReturner magic
-
-
Method Detail
-
warm
public void warm(ConfigRegistry config)
Description copied from interface:ExtensionHandlerCalled after the method handler is constructed to pre-initialize any important configuration data structures.- Specified by:
warmin interfaceExtensionHandler- Overrides:
warmin classCustomizingStatementHandler<PreparedBatch>- Parameters:
config- the method configuration to use for warming up
-
mapToBoolean
private java.util.function.Function<PreparedBatch,ResultIterator<?>> mapToBoolean(java.util.function.Function<PreparedBatch,ResultIterator<?>> modCounts)
-
determineBatchChunkSize
private SqlBatchHandler.ChunkSizeFunction determineBatchChunkSize(java.lang.Class<?> sqlObjectType, java.lang.reflect.Method method)
-
indexOfBatchChunkSizeParameter
private int indexOfBatchChunkSizeParameter(java.lang.reflect.Method method)
-
createStatement
PreparedBatch createStatement(Handle handle, java.lang.String locatedSql)
- Specified by:
createStatementin classCustomizingStatementHandler<PreparedBatch>
-
configureReturner
void configureReturner(PreparedBatch stmt, SqlObjectStatementConfiguration cfg)
- Specified by:
configureReturnerin classCustomizingStatementHandler<PreparedBatch>
-
getParameterType
java.lang.reflect.Type getParameterType(java.lang.reflect.Parameter parameter)
- Overrides:
getParameterTypein classCustomizingStatementHandler<PreparedBatch>
-
invoke
public java.lang.Object invoke(HandleSupplier handleSupplier, java.lang.Object target, java.lang.Object... args)
Description copied from interface:ExtensionHandlerGets invoked to return a value for the method that this handler was bound to.- Specified by:
invokein interfaceExtensionHandler- Overrides:
invokein classCustomizingStatementHandler<PreparedBatch>- Parameters:
handleSupplier- AHandleSupplierinstance for accessing the handle and its related objectstarget- The target object on which the handler should operateargs- Optional arguments for the handler- Returns:
- The return value for the method that was bound to the extension handler. Can be null
-
zipArgs
private java.util.Iterator<java.lang.Object[]> zipArgs(java.lang.reflect.Method method, java.lang.Object[] args)
-
executeBatch
private ResultIterator<?> executeBatch(Handle handle, java.util.function.Supplier<PreparedBatch> preparedBatchSupplier)
-
returnTypeIsValid
private static boolean returnTypeIsValid(java.lang.Class<?> type)
-
invalidReturnTypeMessage
private static java.lang.String invalidReturnTypeMessage(java.lang.reflect.Method method)
-
-