Class ResultSetMapper.Builder
java.lang.Object
com.pyranid.ResultSetMapper.Builder
- Enclosing interface:
ResultSetMapper
Builder used to construct a standard implementation of
ResultSetMapper.
This class is intended for use by a single thread.
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Constructs a defaultResultSetMapperinstance.customColumnMappers(@NonNull List<@NonNull CustomColumnMapper> customColumnMappers) Specifies aListof custom column-specific mapping logic to apply, in priority order.detachLobValues(@NonNull Boolean detachLobValues) Detaches LOBs exposed by native Map/Object mapping, includingObject-typed bean properties and record components, as byte arrays or Strings.failOnUnmappedColumns(@NonNull Boolean failOnUnmappedColumns) Rejects source columns that do not match a writable bean property or record component by throwingDatabaseExceptionwhen the row is mapped.maxLobBytes(@NonNull Long maxLobBytes) Limits each BLOB value materialized by the default mapper asbyte[].maxLobCharacters(@NonNull Long maxLobCharacters) Limits each CLOB/NCLOB value materialized by the default mapper asString, and SQLXML values detached throughdetachLobValues(Boolean).normalizationLocale(@NonNull Locale normalizationLocale) Specifies the locale used for non-ASCII case normalization when matching JDBC column names to Java properties.planCacheCapacity(@NonNull Integer planCacheCapacity) Specifies the maximum number of row-mapping plans to cache per result class when plan caching is enabled.planCachingEnabled(@NonNull Boolean planCachingEnabled) Specifies whether an internal "mapping plan" cache should be used to speed upResultSetmapping.preferredColumnMapperCacheCapacity(@NonNull Integer preferredColumnMapperCacheCapacity) Deprecated, for removal: This API element is subject to removal in a future version.Disables both configurable LOB limits.
-
Method Details
-
normalizationLocale
Specifies the locale used for non-ASCII case normalization when matching JDBC column names to Java properties. ASCII uppercase letters always fold to their ASCII lowercase equivalents before locale-sensitive lowercasing, keeping identifiers such asIDstable under Turkish and Azerbaijani locales. This locale still affects non-ASCII letters; the default isLocale.ROOT.- Parameters:
normalizationLocale- the locale used after locale-independent ASCII folding- Returns:
- this
Builder, for chaining
-
customColumnMappers
public @NonNull ResultSetMapper.Builder customColumnMappers(@NonNull List<@NonNull CustomColumnMapper> customColumnMappers) Specifies aListof custom column-specific mapping logic to apply, in priority order.- Parameters:
customColumnMappers- aListof custom column-specific mapping logic to apply, in priority order- Returns:
- this
Builder, for chaining
-
planCachingEnabled
Specifies whether an internal "mapping plan" cache should be used to speed upResultSetmapping.Disabling plan caching is primarily useful for highly dynamic schemas; plans use the same mapping rules but are compiled without retention.
- Parameters:
planCachingEnabled- whether an internal "mapping plan" cache should be used to speed upResultSetmapping- Returns:
- this
Builder, for chaining
-
planCacheCapacity
Specifies the maximum number of row-mapping plans to cache per result class when plan caching is enabled.Use
0for an unbounded cache.- Parameters:
planCacheCapacity- maximum number of cached plans per result class, or0for unbounded. Defaults toResultSetMapper.DEFAULT_PLAN_CACHE_CAPACITY.- Returns:
- this
Builder, for chaining
-
failOnUnmappedColumns
public @NonNull ResultSetMapper.Builder failOnUnmappedColumns(@NonNull Boolean failOnUnmappedColumns) Rejects source columns that do not match a writable bean property or record component by throwingDatabaseExceptionwhen the row is mapped. Disabled by default. This checks by-name row mappings before built-in column bindings read values; it does not require every target member to be selected. Map rows, scalar values, custom whole-row mappings, and the direct single-STRUCT record fallback keep their existing mapping rules. Validation runs when a row is mapped; empty result sets do not invoke the row mapper.- Parameters:
failOnUnmappedColumns- whether to reject unmatched source columns- Returns:
- this builder
- Since:
- 4.9.0
-
detachLobValues
Detaches LOBs exposed by native Map/Object mapping, includingObject-typed bean properties and record components, as byte arrays or Strings. Disabled by default. BLOBs becomebyte[]; CLOBs, NCLOBs and SQLXML becomeString. Existing byte/character materialization limits apply, including nested Java arrays, collections and maps. Containers are copied without mutating driver values. Explicit JDBC-handle targets and handled custom mapper results retain their ownership contract.- Parameters:
detachLobValues- whether native result values should detach LOBs- Returns:
- this builder
- Since:
- 4.9.0
-
maxLobBytes
Limits each BLOB value materialized by the default mapper asbyte[]. Defaults to 16 MiB. The limit does not cover driver buffering, custom mappers, ordinary binary columns, or the aggregate size of a result list. This setter enables the binary limit even afterunboundedLobMaterialization().- Parameters:
maxLobBytes- strictly positive maximum byte count- Returns:
- this builder
- Since:
- 4.8.0
-
maxLobCharacters
Limits each CLOB/NCLOB value materialized by the default mapper asString, and SQLXML values detached throughdetachLobValues(Boolean). Defaults to 8,388,608 UTF-16 code units. The limit does not cover driver buffering, custom mappers, ordinary character columns, or the aggregate size of a result list. This setter enables the character limit even afterunboundedLobMaterialization().- Parameters:
maxLobCharacters- strictly positive maximum UTF-16 code-unit count- Returns:
- this builder
- Since:
- 4.8.0
-
unboundedLobMaterialization
Disables both configurable LOB limits. Java array and string size limits still apply. Later calls to either finite-limit setter re-enable that limit independently.- Returns:
- this builder
- Since:
- 4.8.0
-
preferredColumnMapperCacheCapacity
@Deprecated(since="4.5.0", forRemoval=true) public @NonNull ResultSetMapper.Builder preferredColumnMapperCacheCapacity(@NonNull Integer preferredColumnMapperCacheCapacity) Deprecated, for removal: This API element is subject to removal in a future version.Retained for source and binary compatibility. This setting has no effect.Pyranid always evaluates applicable custom column mappers in their configured priority order. This method is deprecated and will be removed in 5.0.0.
- Parameters:
preferredColumnMapperCacheCapacity- ignored compatibility value; must be greater than or equal to0- Returns:
- this
Builder, for chaining
-
build
Constructs a defaultResultSetMapperinstance.The constructed instance is thread-safe.
- Returns:
- a
ResultSetMapperinstance
-