Package org.hibernate.loader.ast.spi
Interface MultiKeyLoadSizingStrategy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for determining an optimal size for loading by multiple keys. The
optimal size is defined as the most appropriate number of key values to load
in any single SQL query.
- See Also:
- API Note:
- This is used with IN-list style loading to determine the number of keys to encode into the SQL restriction to make sure we do not exceed database/driver limits on the number of JDBC parameters. Generally, prefer using a SQL ARRAY parameter for the keys instead if the database/driver supports it.
-
Method Summary
Modifier and TypeMethodDescriptionint
determineOptimalBatchLoadSize
(int numberOfKeyColumns, int numberOfKeys, boolean inClauseParameterPaddingEnabled) Determine the optimal batch size (number of key values) to load at a time.
-
Method Details
-
determineOptimalBatchLoadSize
int determineOptimalBatchLoadSize(int numberOfKeyColumns, int numberOfKeys, boolean inClauseParameterPaddingEnabled) Determine the optimal batch size (number of key values) to load at a time. The return can be less than the totalnumberOfKeys
to be loaded indicating that the load should be split across multiple SQL queries. E.g. if we are loading 7 keys and the strategy says the optimal size is 5, we will perform 2 queries.- Parameters:
numberOfKeyColumns
- The number of columns to which the key is mappednumberOfKeys
- The total number of keys we need to loadinClauseParameterPaddingEnabled
- SeeQuerySettings.IN_CLAUSE_PARAMETER_PADDING
- Returns:
- The number of keys to load at once. The total number of JDBC parameters needed for that load is
defined by
numberOfKeys
*numberOfKeyColumns
. The strategy should take care to ensure thatnumberOfKeys
*numberOfKeyColumns
does not exceed any database/driver limits on the number of parameters allowed in a PreparedStatement. - API Note:
-